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

feat(instrumentation-fetch): Add applyCustomAttributesOnSpan option #2071

Merged
merged 6 commits into from
Apr 12, 2021

Conversation

niekert
Copy link
Contributor

@niekert niekert commented Apr 2, 2021

This PR adds an applyCustomAttributesOnSpan function on the instrumentation-fetch package. similar to the API of http(s) plugins.

Fixes #1287

Happy to make changes in tests or implementation if needed

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 2, 2021

CLA Signed

The committers are authorized under a signed CLA.

@codecov
Copy link

codecov bot commented Apr 2, 2021

Codecov Report

Merging #2071 (c4a715d) into main (90a4b4d) will increase coverage by 0.59%.
The diff coverage is 90.90%.

❗ Current head c4a715d differs from pull request most recent head e37cdd8. Consider uploading reports for the commit e37cdd8 to get more accurate results

@@            Coverage Diff             @@
##             main    #2071      +/-   ##
==========================================
+ Coverage   92.14%   92.73%   +0.59%     
==========================================
  Files         120      137      +17     
  Lines        3958     4915     +957     
  Branches      809     1015     +206     
==========================================
+ Hits         3647     4558     +911     
- Misses        311      357      +46     
Impacted Files Coverage Δ
...s/opentelemetry-instrumentation-fetch/src/fetch.ts 98.65% <90.90%> (ø)
...ation-xml-http-request/src/enums/AttributeNames.ts 100.00% <0.00%> (ø)
...ry-context-zone-peer-dep/src/ZoneContextManager.ts 85.18% <0.00%> (ø)
...es/opentelemetry-context-zone-peer-dep/src/util.ts 100.00% <0.00%> (ø)
packages/opentelemetry-web/src/types.ts 100.00% <0.00%> (ø)
...emetry-instrumentation-xml-http-request/src/xhr.ts 96.90% <0.00%> (ø)
...mentation-xml-http-request/src/enums/EventNames.ts 100.00% <0.00%> (ø)
...kages/opentelemetry-exporter-collector/src/util.ts 100.00% <0.00%> (ø)
...ry-exporter-collector/src/CollectorExporterBase.ts 92.30% <0.00%> (ø)
...-instrumentation-fetch/src/enums/AttributeNames.ts 100.00% <0.00%> (ø)
... and 11 more

@niekert niekert changed the title feat(instrumentation-fetch): Add applyCustomAttributesOnSpan option Draft: feat(instrumentation-fetch): Add applyCustomAttributesOnSpan option Apr 2, 2021
@niekert niekert changed the title Draft: feat(instrumentation-fetch): Add applyCustomAttributesOnSpan option feat(instrumentation-fetch): Add applyCustomAttributesOnSpan option Apr 2, 2021
@@ -329,46 +336,51 @@ describe('fetch', () => {
const keys = Object.keys(attributes);

assert.ok(
attributes[keys[0]] !== '',
attributes[AttributeNames.COMPONENT] !== '',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want to modify existing tests too much but the order of attributes changed so perhaps using attribute keys is more accurate?

Copy link
Member

@Flarna Flarna Apr 2, 2021

Choose a reason for hiding this comment

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

Is it possible to use assert.deepStrictEqual?

Copy link
Contributor Author

@niekert niekert Apr 2, 2021

Choose a reason for hiding this comment

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

It's going to be tricky because of the http.user_agent and http.host attribute depend on the context of the test runner I believe thats why these attributes are not checked for equality.

I could make achange to use deepStrictEqual for span attributes that do not depend on environment though, wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed it to assert useragent and host separately and use deepStrictEqual for the other properties 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted the changes to put everything in a new decribe block

Copy link
Member

@obecny obecny left a comment

Choose a reason for hiding this comment

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

lgtm, one final suggestion

packages/opentelemetry-instrumentation-fetch/src/fetch.ts Outdated Show resolved Hide resolved
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.

additional tags for individual spans in fetch plugin
5 participants