Skip to content

fix(instrumentation-xhr): resolve relative URLs before matching ignoreUrls#6551

Merged
pichlermarc merged 4 commits intoopen-telemetry:mainfrom
Maximiliano-Zeballos:fix/xhr-ignore-urls-relative
Apr 23, 2026
Merged

fix(instrumentation-xhr): resolve relative URLs before matching ignoreUrls#6551
pichlermarc merged 4 commits intoopen-telemetry:mainfrom
Maximiliano-Zeballos:fix/xhr-ignore-urls-relative

Conversation

@Maximiliano-Zeballos
Copy link
Copy Markdown
Contributor

Summary

  • The XHR instrumentation was matching the raw URL from XMLHttpRequest.open() against ignoreUrls patterns
  • Relative URLs (e.g. /api/data) would not match domain-based regex patterns (e.g. /.*myapp.*/)
  • The Fetch instrumentation already resolves URLs to absolute form before checking, so this was inconsistent
  • Fix: call parseUrl() before isUrlIgnored() in XHR, aligning behavior with Fetch

Test plan

  • Added test case for relative URL with domain regex in ignoreUrls
  • Existing tests remain unchanged

Fixes #5810

…eUrls

The XHR instrumentation was matching the raw URL from XMLHttpRequest.open()
against ignoreUrls patterns. When a relative URL like '/api/data' was used,
domain-based regex patterns (e.g. /.*myapp.*/) would not match, even though
the same pattern works correctly with the Fetch instrumentation.

This aligns XHR behavior with Fetch by calling parseUrl() to resolve the
URL to its absolute form before checking ignoreUrls.

Fixes open-telemetry#5810
@Maximiliano-Zeballos Maximiliano-Zeballos requested review from a team as code owners April 2, 2026 18:50
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Apr 2, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Maximiliano-Zeballos / name: Maximiliano Zeballos (3c152f6, 95766f5)
  • ✅ login: pichlermarc / name: Marc Pichler (0eef887, 37beace)

@trentm trentm added the browser Browser-specific additions or benefits label Apr 2, 2026
Copy link
Copy Markdown
Contributor

@overbalance overbalance left a comment

Choose a reason for hiding this comment

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

Nice, thanks for the contribution! Please run lint:fix, commit the whitespace change, and make sure to include a changelog entry.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.74%. Comparing base (08c178e) to head (37beace).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6551   +/-   ##
=======================================
  Coverage   95.74%   95.74%           
=======================================
  Files         375      375           
  Lines       12820    12820           
  Branches     3056     3056           
=======================================
  Hits        12274    12274           
  Misses        546      546           
Files with missing lines Coverage Δ
...emetry-instrumentation-xml-http-request/src/xhr.ts 97.61% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread experimental/CHANGELOG.md Outdated
@pichlermarc
Copy link
Copy Markdown
Member

Looks like this got stalled even though it had browser maintainer approval because browser maintainers were not listed as codeowners for the changelog file.

I opened a PR to add them so that browser maintainers can independently merge these PRs in the future (#6622).

@pichlermarc pichlermarc added this pull request to the merge queue Apr 23, 2026
Merged via the queue into open-telemetry:main with commit d0edcbf Apr 23, 2026
27 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Apr 23, 2026

Thank you for your contribution @Maximiliano-Zeballos! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

browser Browser-specific additions or benefits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ignoreUrls RegExp with domain name doesn't work for XHR requests

4 participants