Skip to content

chore(instrumentation-http): provide http.request.header.<key> at server span creation time#6396

Open
vitorvasc wants to merge 3 commits intoopen-telemetry:mainfrom
vitorvasc:instr-http_header-capture
Open

chore(instrumentation-http): provide http.request.header.<key> at server span creation time#6396
vitorvasc wants to merge 3 commits intoopen-telemetry:mainfrom
vitorvasc:instr-http_header-capture

Conversation

@vitorvasc
Copy link
Member

Which problem is this PR solving?

The HTTP semconv spec states that http.request.header.<key> SHOULD be provided at span creation time, as it can be important for making sampling decisions. The current behavior is that instrumentation-http only captures server hequest headers after span creation inside the context.with() callback.

Fixes #6393

Short description of the changes

  • Refactored headerCapture in utils.ts to return an Attributes object instead of calling span.setAttribute() directly.
  • Moved server request header capture in http.ts to before _startHttpSpan, merging the captured attributes into spanOptions.attributes so they are available at span creation time.
  • Updated the remaining heater capture calls to use span.setAttributes() with the returned attributes.

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 unit tests (npm run test in @opentelemetry/instrumentation-http)
  • Lint check (npm run lint)

Checklist:

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

…an creation time

Signed-off-by: Vitor Vasconcellos <vitor.vasconcellos@mercadolivre.com>
@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.50%. Comparing base (fcafab5) to head (1ee20af).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6396   +/-   ##
=======================================
  Coverage   95.50%   95.50%           
=======================================
  Files         365      365           
  Lines       11609    11609           
  Branches     2677     2677           
=======================================
  Hits        11087    11087           
  Misses        522      522           
🚀 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.

Signed-off-by: Vitor Vasconcellos <vitor.vasconcellos@mercadolivre.com>
Signed-off-by: Vitor Vasconcellos <vitor.vasconcellos@mercadolivre.com>
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.

instr-http SHOULD provide http.request.header.<key> at server span creation time

1 participant

Comments