Skip to content

fix(instrumentation-http): remove port from ATTR_CLIENT_ADDRESS#5957

Merged
pichlermarc merged 5 commits intoopen-telemetry:mainfrom
cjihrig:x-forwarded-port
Oct 7, 2025
Merged

fix(instrumentation-http): remove port from ATTR_CLIENT_ADDRESS#5957
pichlermarc merged 5 commits intoopen-telemetry:mainfrom
cjihrig:x-forwarded-port

Conversation

@cjihrig
Copy link
Copy Markdown
Contributor

@cjihrig cjihrig commented Sep 24, 2025

Which problem is this PR solving?

The problem is that ATTR_CLIENT_ADDRESS is being set with a port if one was provided in the relevant headers.

Fixes #5933

Short description of the changes

This commit updates getRemoteClientAddress() to strip any detected ports from the Forwarded or X-Forwarded-For headers. It also increases test coverage for the function.

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

  • Existing test suite
  • Tests added in this PR

Checklist:

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

This commit updates getRemoteClientAddress() to strip any
detected ports from the Forwarded or X-Forwarded-For headers.
It also increases test coverage for the function.

Fixes: open-telemetry#5933
@cjihrig cjihrig requested a review from a team as a code owner September 24, 2025 01:43
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.17%. Comparing base (bfede57) to head (77e5c27).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5957   +/-   ##
=======================================
  Coverage   95.17%   95.17%           
=======================================
  Files         316      316           
  Lines        8521     8521           
  Branches     1763     1763           
=======================================
  Hits         8110     8110           
  Misses        411      411           
🚀 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
@cjihrig
Copy link
Copy Markdown
Contributor Author

cjihrig commented Oct 6, 2025

@pichlermarc could I trouble you for a review?

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.

looks good, thanks 🙂

@pichlermarc pichlermarc added this pull request to the merge queue Oct 7, 2025
Merged via the queue into open-telemetry:main with commit c7f75d9 Oct 7, 2025
25 checks passed
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Oct 7, 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 x-forwarded-port branch October 7, 2025 12:04
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.

opentelemetry-instrumentation-http does not handle x-forwarded-for header with port number

2 participants