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

fix(instrumentation-fetch, instrumentation-xml-http-request) content length attributes missing #5257

Open
wants to merge 6 commits into
base: next
Choose a base branch
from

Conversation

arriIsHere
Copy link
Contributor

Which problem is this PR solving?

http.response_content_length and http.response_content_length_uncompressed attributes are not present on network spans from instrumentation-xml-http-request and instrumentation-fetch plugins when the ignoreNetworkEvents configuration property is set to true

This PR adds the addSpanContentLengthAttributes utility method to @opentelemetry/sdk-trace-web removing the logic for adding content length related attributes from the addSpanNetworkEvents method.

Fixes #5229

Short description of the changes

By skipping over the call to addSpanNetworkEvents the mentioned attributes were not getting added to the main and preflight network spans. We moved the logic for adding the content length attributes to the new addSpanContentLengthAttributes method. This new method will be called regardless of if ignoreNetworkEvents is set to true in the config.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated unit tests were written as well as testing with the fetch and xhr examples to verify the attributes are being added with the proposed code.

  1. Open the examples/opentelemetry-web/examples/fetchexample
  2. Start example
  3. Note that the GET event has a http.response_content_length attribute
  4. Add the ignoreNetworkEvents: true config to the FetchInstrumentation in the index.js file
  5. Run example
  6. The http.response_content_length attribute should still be present on the GET span

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

CHANGELOG.md Outdated
@@ -16,6 +16,7 @@ For semantic convention package changes, see the [semconv CHANGELOG](packages/se
### :bug: (Bug Fix)

* fix(sdk-trace-base): do not load OTEL_ env vars on module load, but when needed [#5224](https://github.com/open-telemetry/opentelemetry-js/pull/5224)
* fix(instrumentation-xhr, instrumentation-fetch): content length attributes no longer get removed with `ignoreNetworkEvents: true` being set [#5229](https://github.com/open-telemetry/opentelemetry-js/issues/5229)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for our confusing changelog setup :/
this should go into CHANGELOG_NEXT.md on this branch.

The fix from main will already be included once this version is released (February), so you can just document the breaking change to sdk-trace-web as feat(sdk-trace-web)!: ... 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if it looks good now. I had a bunch of meetings but am free now.

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for working on this :)
only one changelog nit that we should address, and then we can get this merged 🙂

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.56%. Comparing base (47212bb) to head (ec2d173).
Report is 2 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #5257   +/-   ##
=======================================
  Coverage   94.56%   94.56%           
=======================================
  Files         316      316           
  Lines        8037     8037           
  Branches     1628     1628           
=======================================
  Hits         7600     7600           
  Misses        437      437           

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank you 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants