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): Add allowUrls config option to web instrumentation #4938

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

jairo-mendoza
Copy link

@jairo-mendoza jairo-mendoza commented Aug 21, 2024

Which problem is this PR solving?

This change provides easier control over which urls should have spans created for it. It can also be used with ignoreUrls for more granular control.

Fixes #4899

Short description of the changes

Added allowUrls as a config option to both the XMLHttpRequestInstrumentation and FetchInstrumentation classes.

Addition of the isUrlAllowed function in the core package that both the fetch and xhr instrumentation will depend on.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit tests for both xhr and http instrumentation have been added
  • Tweaked opentelemetry-web examples (fetch and xml-http-request) to accept multiple URLs. Then I added the allowUrls config option on the instrumentation set up and verified that traces were being created (or not created).

Checklist:

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

Copy link

linux-foundation-easycla bot commented Aug 21, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@jairo-mendoza jairo-mendoza changed the title feat: Add allowUrls config option to Fetch Instrumentation feat: Add allowUrls config option to web Instrumentation Aug 21, 2024
@jairo-mendoza jairo-mendoza changed the title feat: Add allowUrls config option to web Instrumentation feat(instrumentation): Add allowUrls config option to web instrumentation Aug 22, 2024
@jairo-mendoza jairo-mendoza marked this pull request as ready for review August 22, 2024 16:06
@jairo-mendoza jairo-mendoza requested a review from a team August 22, 2024 16:06
Copy link
Author

@jairo-mendoza jairo-mendoza left a comment

Choose a reason for hiding this comment

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

Sorry-- fixed a merge conflict and seems like it need reapproval

@jairo-mendoza jairo-mendoza requested a review from a team as a code owner September 24, 2024 15:57
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.18%. Comparing base (fe4d368) to head (4962272).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4938   +/-   ##
=======================================
  Coverage   93.17%   93.18%           
=======================================
  Files         315      315           
  Lines        8086     8094    +8     
  Branches     1617     1619    +2     
=======================================
+ Hits         7534     7542    +8     
  Misses        552      552           
Files with missing lines Coverage Δ
packages/opentelemetry-core/src/utils/url.ts 100.00% <100.00%> (ø)

@jairo-mendoza
Copy link
Author

@pichlermarc Hi, all tests are now passing. Could I get another review and/or be placed in the merge queue? Thanks!

@@ -112,7 +112,7 @@ export {
export { merge } from './utils/merge';
export { TracesSamplerValues } from './utils/sampling';
export { TimeoutError, callWithTimeout } from './utils/timeout';
export { isUrlIgnored, urlMatches } from './utils/url';
export { isUrlAllowed, isUrlIgnored, urlMatches } from './utils/url';
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'd rather have this utility function duplicated across both @opentelemetry/instrumenation-fetch and @opentelemetry/instrumentation-xhr than it being part of the public API of a stable package. It gives us more flexibility to change it later if it's internal. Anything that is stable, we have to support 1 year after the next major so the timeline for changing/removing it would likely be > 1 year.

I'll ask the SIG what people think about combining @opentelemetry/instrumenation-fetch and @opentelemetry/instrumentation-xhr as that has recently come up with #4706 as well - if that goes through we may be able to quite easily de-dupe it when we merge the two packages. That's something for a different PR though.

Copy link
Author

Choose a reason for hiding this comment

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

Gotcha, I'll make those changes soon. Thanks for the review!

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.

Add allowUrls as a config option for web instrumentation
5 participants