fix: stop tracing HTTPS traffic to the agent#7545
Merged
Conversation
PR 2920 made request.js destructure { httpAgent, httpsAgent } from
./agents, but agents.js exported HttpsAgent (PascalCase). Rename the
export to httpsAgent so the consumer gets the agent instead of
undefined.
Contributor
Overall package sizeSelf size: 4.62 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 813.08 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7545 +/- ##
=======================================
Coverage 80.15% 80.15%
=======================================
Files 730 730
Lines 31217 31217
=======================================
Hits 25023 25023
Misses 6194 6194 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 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.

What does this PR do?
Fixes a bug introduced in #2920: the HTTPS agent export in
packages/dd-trace/src/exporters/common/agents.jsis renamed fromHttpsAgenttohttpsAgentso thatrequest.js, which destructures{ httpAgent, httpsAgent }from./agents, receives the HTTPS agent instead ofundefined.Motivation
#2920 moved agent creation into
agents.jsand hadrequest.jsconsumehttpAgentandhttpsAgentfrom there. The new module exportedHttpsAgent(PascalCase), so the destructuring inrequest.jslefthttpsAgentundefined. This PR corrects the export name to match the consumer.Impact
When are users affected? Only when the tracer is configured to use HTTPS to reach the Datadog agent (e.g.
DD_TRACE_AGENT_URL=https://agent.example.com:8126or a remote HTTPS agent). Users using the default HTTP agent URL (e.g.http://localhost:8126) were not affected.Before (bug): For HTTPS agent URLs,
options.agentwas never set (becausehttpsAgentwasundefined). Requests used the defaulthttps.globalAgent. As a result, the tracer would incorrectly start tracing its own HTTPS connections to the agent (see below), and connection pooling did not use the dedicated agent intended by #2920.The tracer's HTTP instrumentation would create spans for its own requests to the agent, so export traffic shows up in your traces. #2920's custom agent runs that connection work in a noop context so it isn't traced; with
httpsAgentundefined, HTTPS requests skipped that and were traced again.After (fix): HTTPS requests to the agent use the shared
httpsAgentfromagents.js. Those connections are no longer traced, and connection pooling matches the design from #2920.