-
Notifications
You must be signed in to change notification settings - Fork 323
Avoid duplicate headers when injecting on java.net http client #10315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+24
−3
Conversation
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
5f1db6d to
e56b785
Compare
vandonr
approved these changes
Jan 8, 2026
dougqh
reviewed
Jan 8, 2026
...et/java-net-11.0/src/main/java11/datadog/trace/instrumentation/httpclient/HeadersAdvice.java
Outdated
Show resolved
Hide resolved
...et/java-net-11.0/src/main/java11/datadog/trace/instrumentation/httpclient/HeadersAdvice.java
Outdated
Show resolved
Hide resolved
mcculls
approved these changes
Jan 8, 2026
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 56 metrics, 9 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.086 s) : 0, 1086487
Total [baseline] (10.9 s) : 0, 10900436
Agent [candidate] (1.086 s) : 0, 1086081
Total [candidate] (10.835 s) : 0, 10834744
section appsec
Agent [baseline] (1.265 s) : 0, 1265367
Total [baseline] (10.958 s) : 0, 10958030
Agent [candidate] (1.265 s) : 0, 1264824
Total [candidate] (10.949 s) : 0, 10948617
section iast
Agent [baseline] (1.23 s) : 0, 1230282
Total [baseline] (11.235 s) : 0, 11235306
Agent [candidate] (1.225 s) : 0, 1225496
Total [candidate] (11.228 s) : 0, 11228460
section profiling
Agent [baseline] (1.206 s) : 0, 1205812
Total [baseline] (10.951 s) : 0, 10951309
Agent [candidate] (1.215 s) : 0, 1215402
Total [candidate] (10.97 s) : 0, 10970059
gantt
title petclinic - break down per module: candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.179 ms) : 0, 1179
crashtracking [candidate] (1.198 ms) : 0, 1198
BytebuddyAgent [baseline] (652.906 ms) : 0, 652906
BytebuddyAgent [candidate] (652.031 ms) : 0, 652031
GlobalTracer [baseline] (282.772 ms) : 0, 282772
GlobalTracer [candidate] (282.733 ms) : 0, 282733
AppSec [baseline] (32.802 ms) : 0, 32802
AppSec [candidate] (32.682 ms) : 0, 32682
Debugger [baseline] (68.007 ms) : 0, 68007
Debugger [candidate] (68.428 ms) : 0, 68428
Remote Config [baseline] (602.472 µs) : 0, 602
Remote Config [candidate] (626.919 µs) : 0, 627
Telemetry [baseline] (9.009 ms) : 0, 9009
Telemetry [candidate] (9.092 ms) : 0, 9092
Flare Poller [baseline] (3.758 ms) : 0, 3758
Flare Poller [candidate] (3.791 ms) : 0, 3791
section appsec
crashtracking [baseline] (1.177 ms) : 0, 1177
crashtracking [candidate] (1.185 ms) : 0, 1185
BytebuddyAgent [baseline] (690.933 ms) : 0, 690933
BytebuddyAgent [candidate] (691.627 ms) : 0, 691627
GlobalTracer [baseline] (258.011 ms) : 0, 258011
GlobalTracer [candidate] (258.141 ms) : 0, 258141
IAST [baseline] (24.48 ms) : 0, 24480
IAST [candidate] (24.583 ms) : 0, 24583
AppSec [baseline] (173.274 ms) : 0, 173274
AppSec [candidate] (172.864 ms) : 0, 172864
Debugger [baseline] (68.026 ms) : 0, 68026
Debugger [candidate] (67.346 ms) : 0, 67346
Remote Config [baseline] (783.232 µs) : 0, 783
Remote Config [candidate] (762.673 µs) : 0, 763
Telemetry [baseline] (9.458 ms) : 0, 9458
Telemetry [candidate] (9.274 ms) : 0, 9274
Flare Poller [baseline] (3.878 ms) : 0, 3878
Flare Poller [candidate] (3.702 ms) : 0, 3702
section iast
crashtracking [baseline] (1.195 ms) : 0, 1195
crashtracking [candidate] (1.178 ms) : 0, 1178
BytebuddyAgent [baseline] (796.466 ms) : 0, 796466
BytebuddyAgent [candidate] (792.256 ms) : 0, 792256
GlobalTracer [baseline] (257.306 ms) : 0, 257306
GlobalTracer [candidate] (256.371 ms) : 0, 256371
IAST [baseline] (27.206 ms) : 0, 27206
IAST [candidate] (27.099 ms) : 0, 27099
AppSec [baseline] (34.714 ms) : 0, 34714
AppSec [candidate] (33.652 ms) : 0, 33652
Debugger [baseline] (65.46 ms) : 0, 65460
Debugger [candidate] (66.763 ms) : 0, 66763
Remote Config [baseline] (546.276 µs) : 0, 546
Remote Config [candidate] (604.851 µs) : 0, 605
Telemetry [baseline] (8.361 ms) : 0, 8361
Telemetry [candidate] (8.583 ms) : 0, 8583
Flare Poller [baseline] (3.552 ms) : 0, 3552
Flare Poller [candidate] (3.615 ms) : 0, 3615
section profiling
crashtracking [baseline] (1.217 ms) : 0, 1217
crashtracking [candidate] (1.228 ms) : 0, 1228
BytebuddyAgent [baseline] (704.115 ms) : 0, 704115
BytebuddyAgent [candidate] (709.036 ms) : 0, 709036
GlobalTracer [baseline] (220.76 ms) : 0, 220760
GlobalTracer [candidate] (222.277 ms) : 0, 222277
AppSec [baseline] (32.154 ms) : 0, 32154
AppSec [candidate] (32.38 ms) : 0, 32380
Debugger [baseline] (68.015 ms) : 0, 68015
Debugger [candidate] (69.2 ms) : 0, 69200
Remote Config [baseline] (658.877 µs) : 0, 659
Remote Config [candidate] (677.409 µs) : 0, 677
Telemetry [baseline] (8.77 ms) : 0, 8770
Telemetry [candidate] (8.939 ms) : 0, 8939
Flare Poller [baseline] (3.706 ms) : 0, 3706
Flare Poller [candidate] (3.764 ms) : 0, 3764
ProfilingAgent [baseline] (96.626 ms) : 0, 96626
ProfilingAgent [candidate] (97.582 ms) : 0, 97582
Profiling [baseline] (97.209 ms) : 0, 97209
Profiling [candidate] (98.159 ms) : 0, 98159
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.083 s) : 0, 1083412
Total [baseline] (8.76 s) : 0, 8760149
Agent [candidate] (1.084 s) : 0, 1084090
Total [candidate] (8.766 s) : 0, 8765716
section iast
Agent [baseline] (1.222 s) : 0, 1222439
Total [baseline] (9.347 s) : 0, 9347374
Agent [candidate] (1.225 s) : 0, 1224771
Total [candidate] (9.337 s) : 0, 9336632
gantt
title insecure-bank - break down per module: candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.185 ms) : 0, 1185
crashtracking [candidate] (1.195 ms) : 0, 1195
BytebuddyAgent [baseline] (651.048 ms) : 0, 651048
BytebuddyAgent [candidate] (651.523 ms) : 0, 651523
GlobalTracer [baseline] (282.183 ms) : 0, 282183
GlobalTracer [candidate] (282.44 ms) : 0, 282440
AppSec [baseline] (32.724 ms) : 0, 32724
AppSec [candidate] (32.615 ms) : 0, 32615
Debugger [baseline] (67.46 ms) : 0, 67460
Debugger [candidate] (67.578 ms) : 0, 67578
Remote Config [baseline] (654.577 µs) : 0, 655
Remote Config [candidate] (616.56 µs) : 0, 617
Telemetry [baseline] (8.956 ms) : 0, 8956
Telemetry [candidate] (8.851 ms) : 0, 8851
Flare Poller [baseline] (3.722 ms) : 0, 3722
Flare Poller [candidate] (3.757 ms) : 0, 3757
section iast
crashtracking [baseline] (1.179 ms) : 0, 1179
crashtracking [candidate] (1.178 ms) : 0, 1178
BytebuddyAgent [baseline] (790.377 ms) : 0, 790377
BytebuddyAgent [candidate] (792.059 ms) : 0, 792059
GlobalTracer [baseline] (255.456 ms) : 0, 255456
GlobalTracer [candidate] (256.244 ms) : 0, 256244
IAST [baseline] (27.012 ms) : 0, 27012
IAST [candidate] (27.072 ms) : 0, 27072
AppSec [baseline] (32.991 ms) : 0, 32991
AppSec [candidate] (33.645 ms) : 0, 33645
Debugger [baseline] (67.337 ms) : 0, 67337
Debugger [candidate] (66.272 ms) : 0, 66272
Remote Config [baseline] (614.106 µs) : 0, 614
Remote Config [candidate] (608.629 µs) : 0, 609
Telemetry [baseline] (8.492 ms) : 0, 8492
Telemetry [candidate] (8.63 ms) : 0, 8630
Flare Poller [baseline] (3.594 ms) : 0, 3594
Flare Poller [candidate] (3.666 ms) : 0, 3666
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 1 performance regressions! Performance is the same for 19 metrics, 16 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section baseline
no_agent (18.346 ms) : 18156, 18536
. : milestone, 18346,
appsec (18.716 ms) : 18528, 18904
. : milestone, 18716,
code_origins (17.934 ms) : 17755, 18113
. : milestone, 17934,
iast (17.583 ms) : 17409, 17757
. : milestone, 17583,
profiling (18.774 ms) : 18583, 18964
. : milestone, 18774,
tracing (17.557 ms) : 17385, 17730
. : milestone, 17557,
section candidate
no_agent (18.317 ms) : 18127, 18507
. : milestone, 18317,
appsec (18.565 ms) : 18376, 18754
. : milestone, 18565,
code_origins (17.747 ms) : 17569, 17926
. : milestone, 17747,
iast (17.641 ms) : 17465, 17818
. : milestone, 17641,
profiling (19.717 ms) : 19518, 19917
. : milestone, 19717,
tracing (17.598 ms) : 17426, 17771
. : milestone, 17598,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section baseline
no_agent (1.18 ms) : 1169, 1192
. : milestone, 1180,
iast (3.179 ms) : 3141, 3216
. : milestone, 3179,
iast_FULL (5.975 ms) : 5915, 6035
. : milestone, 5975,
iast_GLOBAL (3.489 ms) : 3439, 3539
. : milestone, 3489,
profiling (2.033 ms) : 2014, 2052
. : milestone, 2033,
tracing (1.805 ms) : 1790, 1821
. : milestone, 1805,
section candidate
no_agent (1.209 ms) : 1196, 1221
. : milestone, 1209,
iast (3.165 ms) : 3127, 3203
. : milestone, 3165,
iast_FULL (5.791 ms) : 5734, 5848
. : milestone, 5791,
iast_GLOBAL (3.461 ms) : 3412, 3510
. : milestone, 3461,
profiling (2.086 ms) : 2065, 2107
. : milestone, 2086,
tracing (1.772 ms) : 1758, 1787
. : milestone, 1772,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section baseline
no_agent (15.414 s) : 15414000, 15414000
. : milestone, 15414000,
appsec (14.93 s) : 14930000, 14930000
. : milestone, 14930000,
iast (17.883 s) : 17883000, 17883000
. : milestone, 17883000,
iast_GLOBAL (17.798 s) : 17798000, 17798000
. : milestone, 17798000,
profiling (14.845 s) : 14845000, 14845000
. : milestone, 14845000,
tracing (14.406 s) : 14406000, 14406000
. : milestone, 14406000,
section candidate
no_agent (15.311 s) : 15311000, 15311000
. : milestone, 15311000,
appsec (14.582 s) : 14582000, 14582000
. : milestone, 14582000,
iast (17.984 s) : 17984000, 17984000
. : milestone, 17984000,
iast_GLOBAL (18.092 s) : 18092000, 18092000
. : milestone, 18092000,
profiling (14.786 s) : 14786000, 14786000
. : milestone, 14786000,
tracing (14.719 s) : 14719000, 14719000
. : milestone, 14719000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.59.0-SNAPSHOT~ea116a8c71, baseline=1.59.0-SNAPSHOT~419da213f7
dateFormat X
axisFormat %s
section baseline
no_agent (1.473 ms) : 1462, 1485
. : milestone, 1473,
appsec (3.632 ms) : 3416, 3848
. : milestone, 3632,
iast (2.211 ms) : 2146, 2276
. : milestone, 2211,
iast_GLOBAL (2.259 ms) : 2194, 2325
. : milestone, 2259,
profiling (2.067 ms) : 2015, 2120
. : milestone, 2067,
tracing (2.037 ms) : 1986, 2088
. : milestone, 2037,
section candidate
no_agent (1.471 ms) : 1459, 1482
. : milestone, 1471,
appsec (3.708 ms) : 3488, 3928
. : milestone, 3708,
iast (2.224 ms) : 2158, 2289
. : milestone, 2224,
iast_GLOBAL (2.26 ms) : 2194, 2325
. : milestone, 2260,
profiling (2.063 ms) : 2010, 2116
. : milestone, 2063,
tracing (2.039 ms) : 1987, 2090
. : milestone, 2039,
|
...-net-11.0/src/test/groovy/datadog/trace/instrumentation/httpclient/JavaHttpClientTest.groovy
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
inst: others
All other instrumentations
tag: telemetry error reported
Reported by error telemetry
type: bug
Bug report and fix
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 Do
The java-net http client does not tolerate duplicate header names. The issue we have is that, if the host code contains some headers we are also injecting (i.e. x-datadog-trace-id but it can be anything else) that differs in case, we end up in having two keys. The Headers.of method checks for case insensitive duplicates and then throws:
This results in breaking the distributed tracing.
The PR uses a TreeMap with case insensitive ordering to guarantee that there won't be case-insensitive duplicates
Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any useful labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]