Fix Synapse 3.0 instrumentation bugs and harden span propagation#10892
Draft
Fix Synapse 3.0 instrumentation bugs and harden span propagation#10892
Conversation
Three deterministic bugs fixed: 1. Key mismatch in PassthruInstrumentation: PR #9422 renamed the context key constant but forgot to update the hardcoded string literal in SynapsePassthruInstrumentation, breaking parent span propagation across the passthru mechanism. 2. http.url test assertion: QueryObfuscator recombines http.url with the query string after obfuscation. The test expected path-only but the actual value correctly includes the query string. 3. Missing peer.service in V1 client spans: SynapseClientDecorator returns relative URIs (no host), so peer.hostname was never set. Added peer hostname/IP/port extraction from NHttpClientConnection. Additionally, hardened the passthru span propagation to read the server span directly from the source connection context rather than relying solely on activeSpan(). SourceHandler.requestReceived() dispatches to a worker thread pool, and while java-concurrent instrumentation normally handles context propagation across ThreadPoolExecutor, the connection- based lookup is more robust. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 62 metrics, 9 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.065 s) : 0, 1065136
Total [baseline] (8.9 s) : 0, 8899697
Agent [candidate] (1.058 s) : 0, 1057561
Total [candidate] (8.845 s) : 0, 8845299
section iast
Agent [baseline] (1.234 s) : 0, 1233710
Total [baseline] (9.589 s) : 0, 9588891
Agent [candidate] (1.233 s) : 0, 1233402
Total [candidate] (9.575 s) : 0, 9574921
gantt
title insecure-bank - break down per module: candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.223 ms) : 0, 1223
crashtracking [candidate] (1.186 ms) : 0, 1186
BytebuddyAgent [baseline] (634.177 ms) : 0, 634177
BytebuddyAgent [candidate] (629.297 ms) : 0, 629297
AgentMeter [baseline] (29.436 ms) : 0, 29436
AgentMeter [candidate] (29.114 ms) : 0, 29114
GlobalTracer [baseline] (259.003 ms) : 0, 259003
GlobalTracer [candidate] (257.774 ms) : 0, 257774
AppSec [baseline] (32.01 ms) : 0, 32010
AppSec [candidate] (31.726 ms) : 0, 31726
Debugger [baseline] (60.08 ms) : 0, 60080
Debugger [candidate] (59.511 ms) : 0, 59511
Remote Config [baseline] (589.381 µs) : 0, 589
Remote Config [candidate] (588.473 µs) : 0, 588
Telemetry [baseline] (8.814 ms) : 0, 8814
Telemetry [candidate] (8.061 ms) : 0, 8061
Flare Poller [baseline] (3.586 ms) : 0, 3586
Flare Poller [candidate] (4.277 ms) : 0, 4277
section iast
crashtracking [baseline] (1.195 ms) : 0, 1195
crashtracking [candidate] (1.198 ms) : 0, 1198
BytebuddyAgent [baseline] (801.544 ms) : 0, 801544
BytebuddyAgent [candidate] (801.012 ms) : 0, 801012
AgentMeter [baseline] (11.369 ms) : 0, 11369
AgentMeter [candidate] (11.582 ms) : 0, 11582
GlobalTracer [baseline] (248.203 ms) : 0, 248203
GlobalTracer [candidate] (248.194 ms) : 0, 248194
IAST [baseline] (25.477 ms) : 0, 25477
IAST [candidate] (25.478 ms) : 0, 25478
AppSec [baseline] (26.575 ms) : 0, 26575
AppSec [candidate] (26.901 ms) : 0, 26901
Debugger [baseline] (68.103 ms) : 0, 68103
Debugger [candidate] (69.6 ms) : 0, 69600
Remote Config [baseline] (523.775 µs) : 0, 524
Remote Config [candidate] (536.826 µs) : 0, 537
Telemetry [baseline] (10.747 ms) : 0, 10747
Telemetry [candidate] (9.211 ms) : 0, 9211
Flare Poller [baseline] (3.809 ms) : 0, 3809
Flare Poller [candidate] (3.399 ms) : 0, 3399
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.064 s) : 0, 1063959
Total [baseline] (11.102 s) : 0, 11102288
Agent [candidate] (1.066 s) : 0, 1066442
Total [candidate] (11.124 s) : 0, 11123911
section appsec
Agent [baseline] (1.263 s) : 0, 1263263
Total [baseline] (11.232 s) : 0, 11232160
Agent [candidate] (1.244 s) : 0, 1244302
Total [candidate] (11.185 s) : 0, 11184511
section iast
Agent [baseline] (1.227 s) : 0, 1226644
Total [baseline] (11.34 s) : 0, 11339803
Agent [candidate] (1.238 s) : 0, 1238255
Total [candidate] (11.356 s) : 0, 11355786
section profiling
Agent [baseline] (1.188 s) : 0, 1187782
Total [baseline] (10.988 s) : 0, 10987718
Agent [candidate] (1.182 s) : 0, 1182015
Total [candidate] (10.958 s) : 0, 10958381
gantt
title petclinic - break down per module: candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.201 ms) : 0, 1201
crashtracking [candidate] (1.198 ms) : 0, 1198
BytebuddyAgent [baseline] (632.181 ms) : 0, 632181
BytebuddyAgent [candidate] (633.337 ms) : 0, 633337
AgentMeter [baseline] (29.559 ms) : 0, 29559
AgentMeter [candidate] (29.559 ms) : 0, 29559
GlobalTracer [baseline] (259.38 ms) : 0, 259380
GlobalTracer [candidate] (258.536 ms) : 0, 258536
AppSec [baseline] (32.152 ms) : 0, 32152
AppSec [candidate] (31.916 ms) : 0, 31916
Debugger [baseline] (60.925 ms) : 0, 60925
Debugger [candidate] (60.44 ms) : 0, 60440
Remote Config [baseline] (607.56 µs) : 0, 608
Remote Config [candidate] (582.58 µs) : 0, 583
Telemetry [baseline] (8.173 ms) : 0, 8173
Telemetry [candidate] (10.325 ms) : 0, 10325
Flare Poller [baseline] (3.592 ms) : 0, 3592
Flare Poller [candidate] (4.257 ms) : 0, 4257
section appsec
crashtracking [baseline] (1.209 ms) : 0, 1209
crashtracking [candidate] (1.18 ms) : 0, 1180
BytebuddyAgent [baseline] (668.17 ms) : 0, 668170
BytebuddyAgent [candidate] (656.877 ms) : 0, 656877
AgentMeter [baseline] (12.172 ms) : 0, 12172
AgentMeter [candidate] (11.998 ms) : 0, 11998
GlobalTracer [baseline] (261.097 ms) : 0, 261097
GlobalTracer [candidate] (257.752 ms) : 0, 257752
IAST [baseline] (24.626 ms) : 0, 24626
IAST [candidate] (24.128 ms) : 0, 24128
AppSec [baseline] (179.435 ms) : 0, 179435
AppSec [candidate] (177.574 ms) : 0, 177574
Debugger [baseline] (67.137 ms) : 0, 67137
Debugger [candidate] (65.939 ms) : 0, 65939
Remote Config [baseline] (629.87 µs) : 0, 630
Remote Config [candidate] (618.131 µs) : 0, 618
Telemetry [baseline] (8.479 ms) : 0, 8479
Telemetry [candidate] (8.337 ms) : 0, 8337
Flare Poller [baseline] (3.637 ms) : 0, 3637
Flare Poller [candidate] (3.582 ms) : 0, 3582
section iast
crashtracking [baseline] (1.21 ms) : 0, 1210
crashtracking [candidate] (1.21 ms) : 0, 1210
BytebuddyAgent [baseline] (795.273 ms) : 0, 795273
BytebuddyAgent [candidate] (804.026 ms) : 0, 804026
AgentMeter [baseline] (11.332 ms) : 0, 11332
AgentMeter [candidate] (11.622 ms) : 0, 11622
GlobalTracer [baseline] (247.274 ms) : 0, 247274
GlobalTracer [candidate] (249.112 ms) : 0, 249112
IAST [baseline] (25.279 ms) : 0, 25279
IAST [candidate] (25.54 ms) : 0, 25540
AppSec [baseline] (26.452 ms) : 0, 26452
AppSec [candidate] (26.787 ms) : 0, 26787
Debugger [baseline] (70.597 ms) : 0, 70597
Debugger [candidate] (70.629 ms) : 0, 70629
Remote Config [baseline] (522.703 µs) : 0, 523
Remote Config [candidate] (531.173 µs) : 0, 531
Telemetry [baseline] (9.163 ms) : 0, 9163
Telemetry [candidate] (9.188 ms) : 0, 9188
Flare Poller [baseline] (3.375 ms) : 0, 3375
Flare Poller [candidate] (3.322 ms) : 0, 3322
section profiling
crashtracking [baseline] (1.175 ms) : 0, 1175
crashtracking [candidate] (1.177 ms) : 0, 1177
BytebuddyAgent [baseline] (686.344 ms) : 0, 686344
BytebuddyAgent [candidate] (683.149 ms) : 0, 683149
AgentMeter [baseline] (8.607 ms) : 0, 8607
AgentMeter [candidate] (8.586 ms) : 0, 8586
GlobalTracer [baseline] (216.009 ms) : 0, 216009
GlobalTracer [candidate] (215.129 ms) : 0, 215129
AppSec [baseline] (32.341 ms) : 0, 32341
AppSec [candidate] (32.172 ms) : 0, 32172
Debugger [baseline] (66.334 ms) : 0, 66334
Debugger [candidate] (63.562 ms) : 0, 63562
Remote Config [baseline] (559.017 µs) : 0, 559
Remote Config [candidate] (583.471 µs) : 0, 583
Telemetry [baseline] (7.767 ms) : 0, 7767
Telemetry [candidate] (10.065 ms) : 0, 10065
Flare Poller [baseline] (3.477 ms) : 0, 3477
Flare Poller [candidate] (3.417 ms) : 0, 3417
ProfilingAgent [baseline] (94.075 ms) : 0, 94075
ProfilingAgent [candidate] (93.345 ms) : 0, 93345
Profiling [baseline] (94.637 ms) : 0, 94637
Profiling [candidate] (93.911 ms) : 0, 93911
LoadParameters
See matching parameters
SummaryFound 3 performance improvements and 2 performance regressions! Performance is the same for 15 metrics, 16 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section baseline
no_agent (1.188 ms) : 1177, 1200
. : milestone, 1188,
iast (3.217 ms) : 3170, 3264
. : milestone, 3217,
iast_FULL (5.698 ms) : 5641, 5754
. : milestone, 5698,
iast_GLOBAL (3.614 ms) : 3553, 3674
. : milestone, 3614,
profiling (2.078 ms) : 2060, 2097
. : milestone, 2078,
tracing (1.791 ms) : 1777, 1806
. : milestone, 1791,
section candidate
no_agent (1.182 ms) : 1171, 1193
. : milestone, 1182,
iast (3.119 ms) : 3077, 3162
. : milestone, 3119,
iast_FULL (5.782 ms) : 5725, 5839
. : milestone, 5782,
iast_GLOBAL (3.494 ms) : 3435, 3553
. : milestone, 3494,
profiling (2.015 ms) : 1997, 2032
. : milestone, 2015,
tracing (1.77 ms) : 1755, 1785
. : milestone, 1770,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section baseline
no_agent (18.327 ms) : 18131, 18522
. : milestone, 18327,
appsec (18.394 ms) : 18205, 18583
. : milestone, 18394,
code_origins (17.871 ms) : 17692, 18050
. : milestone, 17871,
iast (18.769 ms) : 18578, 18960
. : milestone, 18769,
profiling (20.218 ms) : 20015, 20420
. : milestone, 20218,
tracing (17.345 ms) : 17175, 17514
. : milestone, 17345,
section candidate
no_agent (18.946 ms) : 18751, 19140
. : milestone, 18946,
appsec (18.328 ms) : 18143, 18513
. : milestone, 18328,
code_origins (17.703 ms) : 17528, 17877
. : milestone, 17703,
iast (17.523 ms) : 17348, 17698
. : milestone, 17523,
profiling (19.741 ms) : 19540, 19942
. : milestone, 19741,
tracing (18.73 ms) : 18544, 18917
. : milestone, 18730,
DacapoParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 0 unstable metrics.
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section baseline
no_agent (1.471 ms) : 1459, 1482
. : milestone, 1471,
appsec (3.793 ms) : 3573, 4012
. : milestone, 3793,
iast (2.244 ms) : 2176, 2313
. : milestone, 2244,
iast_GLOBAL (2.285 ms) : 2216, 2354
. : milestone, 2285,
profiling (2.085 ms) : 2030, 2141
. : milestone, 2085,
tracing (2.065 ms) : 2012, 2118
. : milestone, 2065,
section candidate
no_agent (1.472 ms) : 1461, 1484
. : milestone, 1472,
appsec (2.508 ms) : 2454, 2563
. : milestone, 2508,
iast (2.251 ms) : 2182, 2320
. : milestone, 2251,
iast_GLOBAL (2.277 ms) : 2209, 2346
. : milestone, 2277,
profiling (2.093 ms) : 2037, 2149
. : milestone, 2093,
tracing (2.067 ms) : 2014, 2121
. : milestone, 2067,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.61.0-SNAPSHOT~acc4558be4, baseline=1.61.0-SNAPSHOT~f4fa29a892
dateFormat X
axisFormat %s
section baseline
no_agent (14.844 s) : 14844000, 14844000
. : milestone, 14844000,
appsec (14.714 s) : 14714000, 14714000
. : milestone, 14714000,
iast (18.047 s) : 18047000, 18047000
. : milestone, 18047000,
iast_GLOBAL (17.892 s) : 17892000, 17892000
. : milestone, 17892000,
profiling (15.052 s) : 15052000, 15052000
. : milestone, 15052000,
tracing (15.336 s) : 15336000, 15336000
. : milestone, 15336000,
section candidate
no_agent (15.113 s) : 15113000, 15113000
. : milestone, 15113000,
appsec (14.683 s) : 14683000, 14683000
. : milestone, 14683000,
iast (18.233 s) : 18233000, 18233000
. : milestone, 18233000,
iast_GLOBAL (17.998 s) : 17998000, 17998000
. : milestone, 17998000,
profiling (14.902 s) : 14902000, 14902000
. : milestone, 14902000,
tracing (15.279 s) : 15279000, 15279000
. : milestone, 15279000,
|
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 Do
Fixes three deterministic bugs in the Synapse 3.0 instrumentation and hardens span propagation across the passthru mechanism.
Motivation
The Synapse tests have been
@Flakysince 2023. Investigation revealed three deterministic bugs introduced or exposed over time:Bug 1: Key mismatch in PassthruInstrumentation
PR #9422 renamed the context key constant in
SynapseClientDecoratorfrom"dd.trace.synapse.span"to"dd.trace.synapse.context"but forgot to update the hardcoded string literal inSynapsePassthruInstrumentation. The client instrumentation could never find the parent span, breaking trace linkage in proxy scenarios.Fix: Use the
SYNAPSE_CONTEXT_KEYconstant instead of the hardcoded string.Bug 2: http.url test assertion wrong
QueryObfuscator(a tag post-processor) intentionally recombineshttp.url+http.query.stringafter obfuscation. The test expected path-onlyhttp.urlbut the actual value correctly includes the query string — matching the behavior of all other HTTP server instrumentation tests.Fix: Updated
serverSpanassertion to include the query string inhttp.urlwhen present.Bug 3: Missing peer.service in V1 client spans
SynapseClientDecorator.url()returns relative URIs (no host), soUriBasedClientDecorator.onURI()never setpeer.hostname. Without it, V1 naming (PeerServiceNamingV1) can't computepeer.service.Fix: Added peer hostname/IP/port extraction from
NHttpClientConnectioninClientRequestAdvice.Robustness: Connection-based span propagation
SourceHandler.requestReceived()dispatches request processing to a worker thread pool (NativeWorkerPool→ThreadPoolExecutor). The passthru advice previously relied onactiveSpan()(thread-local) which depends onjava-concurrentinstrumentation propagating context across the thread pool. The fix reads the server span directly from the source connection's context (whereSynapseServerInstrumentationstored it), withactiveSpan()as fallback.Additional Notes
@Flakyannotation kept on the base test class for monitoring — the original annotation predates these bugs (added 2023)Jira ticket: N/A
🤖 Generated with Claude Code