feat(instrumentation-http): add an experimental useDiagnosticsChannel option - #6947
Open
YangJonghun wants to merge 3 commits into
Open
feat(instrumentation-http): add an experimental useDiagnosticsChannel option#6947YangJonghun wants to merge 3 commits into
useDiagnosticsChannel option#6947YangJonghun wants to merge 3 commits into
Conversation
Pull request dashboard statusWaiting on reviewers · refreshed 2026-07-30 13:48 UTC Review the latest changes. Status above doesn't look right?
|
- subscribe to `http.client.request.created` / `http.server.request.start` instead of patching module exports - reuse existing span, propagation, and metrics code paths - enabled by config, or the `OTEL_INSTRUMENTATION_HTTP_USE_DIAGNOSTICS_CHANNEL` env var when the config is not set - falls back to patching on runtimes without the channels (Node.js <22.12.0, or <23.2.0 on 23.x)
YangJonghun
force-pushed
the
feat/http-diagnostics-channel
branch
from
July 26, 2026 14:22
06aff93 to
5f33beb
Compare
…annel path - test:cjs:diagch re-runs the suites with the env var set (mocah --require) - new functional suite: version gate, option/env resolution, injection, Expect: 100-continue, proxied absolute-form paths - patching-only behavior (nock, throw before ClientRequest, isWrapped) is skipped in channel mode; assertions unchanged otherwise
YangJonghun
force-pushed
the
feat/http-diagnostics-channel
branch
from
July 26, 2026 15:46
5f33beb to
37bc69b
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6947 +/- ##
========================================
Coverage 95.07% 95.07%
========================================
Files 409 410 +1
Lines 14256 14406 +150
Branches 3267 3306 +39
========================================
+ Hits 13554 13697 +143
- Misses 702 709 +7
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
Patching the
http/httpsexports only works when the instrumentation is registered before the modules are loaded, which isn't always possible. Since Node.js22.12.0/23.2.0there is ahttp.client.request.createddiagnostics channel has fired before the headers are flushed, allowing propagation headers to be injected without patching - this was the blocker in #4319 .Fixes #4319
Short description of the changes
Add an experimental
useDiagnosticsChanneloption, which can also be set via theOTEL_INSTRUMENTATION_HTTP_USE_DIAGNOSTICS_CHANNELenv var. When enabled, the instrumentation subscribes tohttp.client.request.createdandhttp.server.request.startand reuses the existing span & metrics code paths, so that the resulting telemetry remains consistent with patching mode. On runtimes without these channels, it falls back to patching.Known limitations
Expect: 100-continuerequests can't have propagation headers injected because the headers have already been flushed when the channel fires.ClientRequest(invalid options, nock) aren't observable because the channels are never published.Authorization: Basicheader set directly by the caller can't be distinguished from one generated from theauthoption. As a result,url.fullmay containREDACTEDcredentials even though the request URL had none. This results only in over-redaction; nothing is leaked.Type of change
How Has This Been Tested?
npm test.Checklist: