Skip to content

refactor(instrumentation-http): avoid deprecated url.parse() in getAbsoluteUrl()#6089

Merged
pichlermarc merged 3 commits intoopen-telemetry:mainfrom
cjihrig:url-parse
Nov 10, 2025
Merged

refactor(instrumentation-http): avoid deprecated url.parse() in getAbsoluteUrl()#6089
pichlermarc merged 3 commits intoopen-telemetry:mainfrom
cjihrig:url-parse

Conversation

@cjihrig
Copy link
Copy Markdown
Contributor

@cjihrig cjihrig commented Nov 6, 2025

Which problem is this PR solving?

getAbsoluteUrl() uses url.parse(), which is deprecated in Node.js. new URL() is preferable.

Does not fix all occurrences of url.parse(), but refers to #6061.

Short description of the changes

This commit updates getAbsoluteUrl() to use new URL() instead of the deprecated url.parse(). As a side effect, the code is a bit simpler.

There are some remaining occurrences in tests, but I would prefer to update those separately.

Type of change

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

How Has This Been Tested?

  • Test suite.

Checklist:

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

@cjihrig cjihrig requested a review from a team as a code owner November 6, 2025 12:46
Comment thread experimental/CHANGELOG.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.16%. Comparing base (32336f1) to head (55504b4).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6089   +/-   ##
=======================================
  Coverage   95.16%   95.16%           
=======================================
  Files         316      316           
  Lines        9207     9207           
  Branches     2075     2075           
=======================================
  Hits         8762     8762           
  Misses        445      445           
🚀 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.

Copy link
Copy Markdown
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.

Hmm, I think there may be some edge-cases where the instrumentation would throw, but http/https itself would not.

Comment thread experimental/packages/opentelemetry-instrumentation-http/src/utils.ts Outdated
Copy link
Copy Markdown
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.

thanks!

@pichlermarc pichlermarc added this pull request to the merge queue Nov 10, 2025
Merged via the queue into open-telemetry:main with commit bcf1517 Nov 10, 2025
27 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Nov 10, 2025

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

@cjihrig cjihrig deleted the url-parse branch November 10, 2025 14:50
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