Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROF-9821] Fix incorrect code provenance due to broken JSON monkey patch #3695

Merged

Commits on Jun 10, 2024

  1. [PROF-9821] Fix incorrect code provenance due to broken JSON monkey p…

    …atch
    
    **What does this PR do?**
    
    This PR tweaks the
    `Datadog::Profiling::Collectors::CodeProvenance::Library` class so that
    if it is encoded instance-filed-by-instance-field it results in a
    correct code provenance JSON file.
    
    Specifically, the `path` argument is now stored as a `paths` array, to
    match what we expect in the JSON file.
    
    **Motivation:**
    
    We've discovered that in a certain combination of the oj and
    activesupport libraries, when oj is used to replace the standard library
    JSON gem, it incorrectly encodes our `Library` instances
    instance-field-by-instance-field instead of calling `#to_json`.
    
    This resulted in incorrect code provenance files, which would be
    rejected by the backend.
    
    Since the change is trivial (`path` => `paths` array), I've opted to
    change the shape of `Library` so that it still encodes correctly in
    the presence of a buggy JSON encoder monkey patch.
    
    **Additional Notes:**
    
    N/A
    
    **How to test the change?**
    
    I've added coverage to this issue. I did it in a bit of a roundabout way
    (using YAML), see details for why, but I claim it's a reasonable proxy
    for any encoder that encodes field-by-field, including oj.
    ivoanjo committed Jun 10, 2024
    Configuration menu
    Copy the full SHA
    63efb3e View commit details
    Browse the repository at this point in the history