-
Notifications
You must be signed in to change notification settings - Fork 320
Context API beforeFinish Migration
#9422
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
Conversation
* Creates inferred proxy spans for API Gateway calls via presence of http headers --------- Co-authored-by: Zarir Hamza <[email protected]>
Avoid duplicate expensive context extraction Avoid subclassing tracing span for serverless but used serverless context element instead to store / track inferred span while keep tracing feature untouched Improved propagator to not create / capture inferred span context element on invalid data Rework context element to hold the inferred spans and its captured data Release captured data as soon as they span start (never read after this point so reclaiming memory) Refactor context element and propagator into the right package, not context component (product / feature agnostic) Refactor unit tests
|
🎯 Code Coverage 🔗 Commit SHA: 82884df | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 59 metrics, 6 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.102 s) : 0, 1101561
Total [baseline] (8.805 s) : 0, 8805351
Agent [candidate] (1.107 s) : 0, 1107110
Total [candidate] (8.872 s) : 0, 8871698
section iast
Agent [baseline] (1.246 s) : 0, 1246105
Total [baseline] (9.567 s) : 0, 9567405
Agent [candidate] (1.248 s) : 0, 1248465
Total [candidate] (9.615 s) : 0, 9615392
gantt
title insecure-bank - break down per module: candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.453 ms) : 0, 1453
crashtracking [candidate] (1.454 ms) : 0, 1454
BytebuddyAgent [baseline] (704.6 ms) : 0, 704600
BytebuddyAgent [candidate] (706.964 ms) : 0, 706964
GlobalTracer [baseline] (247.857 ms) : 0, 247857
GlobalTracer [candidate] (250.04 ms) : 0, 250040
AppSec [baseline] (32.272 ms) : 0, 32272
AppSec [candidate] (32.629 ms) : 0, 32629
Debugger [baseline] (68.342 ms) : 0, 68342
Debugger [candidate] (68.763 ms) : 0, 68763
Remote Config [baseline] (634.748 µs) : 0, 635
Remote Config [candidate] (640.864 µs) : 0, 641
Telemetry [baseline] (8.11 ms) : 0, 8110
Telemetry [candidate] (8.183 ms) : 0, 8183
Flare Poller [baseline] (3.683 ms) : 0, 3683
Flare Poller [candidate] (3.753 ms) : 0, 3753
section iast
crashtracking [baseline] (1.462 ms) : 0, 1462
crashtracking [candidate] (1.444 ms) : 0, 1444
BytebuddyAgent [baseline] (834.354 ms) : 0, 834354
BytebuddyAgent [candidate] (834.441 ms) : 0, 834441
GlobalTracer [baseline] (237.611 ms) : 0, 237611
GlobalTracer [candidate] (238.342 ms) : 0, 238342
AppSec [baseline] (31.279 ms) : 0, 31279
AppSec [candidate] (31.522 ms) : 0, 31522
Debugger [baseline] (65.093 ms) : 0, 65093
Debugger [candidate] (65.611 ms) : 0, 65611
Remote Config [baseline] (559.998 µs) : 0, 560
Remote Config [candidate] (553.94 µs) : 0, 554
Telemetry [baseline] (7.71 ms) : 0, 7710
Telemetry [candidate] (7.741 ms) : 0, 7741
Flare Poller [baseline] (3.579 ms) : 0, 3579
Flare Poller [candidate] (3.645 ms) : 0, 3645
IAST [baseline] (29.732 ms) : 0, 29732
IAST [candidate] (30.547 ms) : 0, 30547
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.105 s) : 0, 1104522
Total [baseline] (10.742 s) : 0, 10741876
Agent [candidate] (1.103 s) : 0, 1103452
Total [candidate] (10.767 s) : 0, 10767187
section appsec
Agent [baseline] (1.279 s) : 0, 1278500
Total [baseline] (11.084 s) : 0, 11084440
Agent [candidate] (1.281 s) : 0, 1281321
Total [candidate] (11.117 s) : 0, 11117471
section iast
Agent [baseline] (1.24 s) : 0, 1240422
Total [baseline] (11.274 s) : 0, 11274084
Agent [candidate] (1.244 s) : 0, 1244412
Total [candidate] (11.26 s) : 0, 11259728
section profiling
Agent [baseline] (1.228 s) : 0, 1227674
Total [baseline] (10.999 s) : 0, 10999091
Agent [candidate] (1.232 s) : 0, 1231690
Total [candidate] (11.058 s) : 0, 11058387
gantt
title petclinic - break down per module: candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.452 ms) : 0, 1452
crashtracking [candidate] (1.458 ms) : 0, 1458
BytebuddyAgent [baseline] (706.148 ms) : 0, 706148
BytebuddyAgent [candidate] (703.662 ms) : 0, 703662
GlobalTracer [baseline] (248.53 ms) : 0, 248530
GlobalTracer [candidate] (249.328 ms) : 0, 249328
AppSec [baseline] (32.42 ms) : 0, 32420
AppSec [candidate] (32.494 ms) : 0, 32494
Debugger [baseline] (68.827 ms) : 0, 68827
Debugger [candidate] (69.283 ms) : 0, 69283
Remote Config [baseline] (630.808 µs) : 0, 631
Remote Config [candidate] (632.69 µs) : 0, 633
Telemetry [baseline] (8.18 ms) : 0, 8180
Telemetry [candidate] (8.281 ms) : 0, 8281
Flare Poller [baseline] (3.714 ms) : 0, 3714
Flare Poller [candidate] (3.697 ms) : 0, 3697
section appsec
crashtracking [baseline] (1.447 ms) : 0, 1447
crashtracking [candidate] (1.463 ms) : 0, 1463
BytebuddyAgent [baseline] (728.96 ms) : 0, 728960
BytebuddyAgent [candidate] (730.513 ms) : 0, 730513
GlobalTracer [baseline] (240.342 ms) : 0, 240342
GlobalTracer [candidate] (241.637 ms) : 0, 241637
AppSec [baseline] (173.823 ms) : 0, 173823
AppSec [candidate] (174.167 ms) : 0, 174167
Debugger [baseline] (61.432 ms) : 0, 61432
Debugger [candidate] (60.853 ms) : 0, 60853
Remote Config [baseline] (656.429 µs) : 0, 656
Remote Config [candidate] (661.377 µs) : 0, 661
Telemetry [baseline] (8.424 ms) : 0, 8424
Telemetry [candidate] (8.326 ms) : 0, 8326
Flare Poller [baseline] (3.877 ms) : 0, 3877
Flare Poller [candidate] (3.846 ms) : 0, 3846
IAST [baseline] (24.833 ms) : 0, 24833
IAST [candidate] (25.019 ms) : 0, 25019
section iast
crashtracking [baseline] (1.454 ms) : 0, 1454
crashtracking [candidate] (1.447 ms) : 0, 1447
BytebuddyAgent [baseline] (827.68 ms) : 0, 827680
BytebuddyAgent [candidate] (830.606 ms) : 0, 830606
GlobalTracer [baseline] (237.225 ms) : 0, 237225
GlobalTracer [candidate] (238.332 ms) : 0, 238332
AppSec [baseline] (30.557 ms) : 0, 30557
AppSec [candidate] (33.179 ms) : 0, 33179
Debugger [baseline] (66.173 ms) : 0, 66173
Debugger [candidate] (65.89 ms) : 0, 65890
Remote Config [baseline] (554.906 µs) : 0, 555
Remote Config [candidate] (544.072 µs) : 0, 544
Telemetry [baseline] (7.79 ms) : 0, 7790
Telemetry [candidate] (7.699 ms) : 0, 7699
Flare Poller [baseline] (3.634 ms) : 0, 3634
Flare Poller [candidate] (3.531 ms) : 0, 3531
IAST [baseline] (30.721 ms) : 0, 30721
IAST [candidate] (28.371 ms) : 0, 28371
section profiling
ProfilingAgent [baseline] (96.018 ms) : 0, 96018
ProfilingAgent [candidate] (96.515 ms) : 0, 96515
crashtracking [baseline] (1.417 ms) : 0, 1417
crashtracking [candidate] (1.44 ms) : 0, 1440
BytebuddyAgent [baseline] (727.731 ms) : 0, 727731
BytebuddyAgent [candidate] (729.814 ms) : 0, 729814
GlobalTracer [baseline] (221.312 ms) : 0, 221312
GlobalTracer [candidate] (221.934 ms) : 0, 221934
AppSec [baseline] (32.125 ms) : 0, 32125
AppSec [candidate] (32.283 ms) : 0, 32283
Debugger [baseline] (67.347 ms) : 0, 67347
Debugger [candidate] (67.767 ms) : 0, 67767
Remote Config [baseline] (652.299 µs) : 0, 652
Remote Config [candidate] (635.277 µs) : 0, 635
Telemetry [baseline] (7.839 ms) : 0, 7839
Telemetry [candidate] (7.873 ms) : 0, 7873
Flare Poller [baseline] (3.732 ms) : 0, 3732
Flare Poller [candidate] (3.764 ms) : 0, 3764
Profiling [baseline] (96.586 ms) : 0, 96586
Profiling [candidate] (97.096 ms) : 0, 97096
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 3 performance regressions! Performance is the same for 17 metrics, 16 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section baseline
no_agent (1.202 ms) : 1190, 1213
. : milestone, 1202,
iast (3.204 ms) : 3156, 3252
. : milestone, 3204,
iast_FULL (5.721 ms) : 5648, 5794
. : milestone, 5721,
iast_GLOBAL (3.547 ms) : 3492, 3602
. : milestone, 3547,
profiling (1.899 ms) : 1883, 1915
. : milestone, 1899,
tracing (1.853 ms) : 1837, 1869
. : milestone, 1853,
section candidate
no_agent (1.183 ms) : 1171, 1194
. : milestone, 1183,
iast (3.195 ms) : 3153, 3236
. : milestone, 3195,
iast_FULL (5.778 ms) : 5720, 5837
. : milestone, 5778,
iast_GLOBAL (3.596 ms) : 3476, 3717
. : milestone, 3596,
profiling (2.056 ms) : 2038, 2074
. : milestone, 2056,
tracing (1.798 ms) : 1783, 1813
. : milestone, 1798,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section baseline
no_agent (18.132 ms) : 17947, 18318
. : milestone, 18132,
appsec (18.61 ms) : 18424, 18796
. : milestone, 18610,
code_origins (17.899 ms) : 17722, 18076
. : milestone, 17899,
iast (17.893 ms) : 17716, 18069
. : milestone, 17893,
profiling (18.783 ms) : 18594, 18971
. : milestone, 18783,
tracing (17.489 ms) : 17315, 17662
. : milestone, 17489,
section candidate
no_agent (18.263 ms) : 18075, 18451
. : milestone, 18263,
appsec (19.615 ms) : 19415, 19814
. : milestone, 19615,
code_origins (17.681 ms) : 17506, 17856
. : milestone, 17681,
iast (18.318 ms) : 18133, 18503
. : milestone, 18318,
profiling (18.482 ms) : 18296, 18668
. : milestone, 18482,
tracing (17.58 ms) : 17407, 17753
. : milestone, 17580,
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.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section baseline
no_agent (15.626 s) : 15626000, 15626000
. : milestone, 15626000,
appsec (15.184 s) : 15184000, 15184000
. : milestone, 15184000,
iast (18.575 s) : 18575000, 18575000
. : milestone, 18575000,
iast_GLOBAL (18.019 s) : 18019000, 18019000
. : milestone, 18019000,
profiling (14.847 s) : 14847000, 14847000
. : milestone, 14847000,
tracing (14.73 s) : 14730000, 14730000
. : milestone, 14730000,
section candidate
no_agent (15.631 s) : 15631000, 15631000
. : milestone, 15631000,
appsec (14.912 s) : 14912000, 14912000
. : milestone, 14912000,
iast (18.338 s) : 18338000, 18338000
. : milestone, 18338000,
iast_GLOBAL (18.057 s) : 18057000, 18057000
. : milestone, 18057000,
profiling (15.026 s) : 15026000, 15026000
. : milestone, 15026000,
tracing (14.543 s) : 14543000, 14543000
. : milestone, 14543000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.53.0-SNAPSHOT~82884df8d7, baseline=1.56.0-SNAPSHOT~83fdea5642
dateFormat X
axisFormat %s
section baseline
no_agent (1.47 ms) : 1459, 1482
. : milestone, 1470,
appsec (3.563 ms) : 3356, 3771
. : milestone, 3563,
iast (2.205 ms) : 2142, 2269
. : milestone, 2205,
iast_GLOBAL (2.234 ms) : 2171, 2297
. : milestone, 2234,
profiling (2.048 ms) : 1996, 2100
. : milestone, 2048,
tracing (2.015 ms) : 1966, 2064
. : milestone, 2015,
section candidate
no_agent (1.475 ms) : 1463, 1486
. : milestone, 1475,
appsec (3.625 ms) : 3411, 3839
. : milestone, 3625,
iast (2.191 ms) : 2128, 2254
. : milestone, 2191,
iast_GLOBAL (2.236 ms) : 2172, 2299
. : milestone, 2236,
profiling (2.066 ms) : 2013, 2119
. : milestone, 2066,
tracing (2.014 ms) : 1965, 2063
. : milestone, 2014,
|
...er-10.0/src/main/java11/datadog/trace/instrumentation/jetty10/JettyCommitResponseHelper.java
Outdated
Show resolved
Hide resolved
...ver/jetty-server-10.0/src/main/java11/datadog/trace/instrumentation/jetty10/ResetAdvice.java
Outdated
Show resolved
Hide resolved
...ava/datadog/trace/instrumentation/vertx_4_0/client/HttpClientRequestBaseInstrumentation.java
Show resolved
Hide resolved
...at/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/RequestInstrumentation.java
Show resolved
Hide resolved
.../main/java/datadog/trace/instrumentation/netty40/client/HttpClientRequestTracingHandler.java
Outdated
Show resolved
Hide resolved
.../main/java/datadog/trace/instrumentation/netty41/client/HttpClientRequestTracingHandler.java
Outdated
Show resolved
Hide resolved
.../main/java/datadog/trace/instrumentation/netty41/client/HttpClientRequestTracingHandler.java
Show resolved
Hide resolved
...main/java/datadog/trace/instrumentation/netty41/client/HttpClientResponseTracingHandler.java
Outdated
Show resolved
Hide resolved
...ng-webmvc-6.0/src/main/java17/datadog/trace/instrumentation/springweb6/ControllerAdvice.java
Show resolved
Hide resolved
...e-3.0/src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerInstrumentation.java
Outdated
Show resolved
Hide resolved
...src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerWorkerInstrumentation.java
Outdated
Show resolved
Hide resolved
...t/tomcat-5.5/src/main/java/datadog/trace/instrumentation/tomcat/ResponseInstrumentation.java
Show resolved
Hide resolved
...dertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/ExchangeEndSpanListener.java
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/undertow/HttpRequestParserInstrumentation.java
Outdated
Show resolved
Hide resolved
mhlidd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few small questions/nits
...src/main/java/datadog/trace/instrumentation/synapse3/SynapseClientWorkerInstrumentation.java
Outdated
Show resolved
Hide resolved
...src/main/java/datadog/trace/instrumentation/synapse3/SynapseServerWorkerInstrumentation.java
Show resolved
Hide resolved
...dertow-2.0/src/main/java/datadog/trace/instrumentation/undertow/ExchangeEndSpanListener.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/undertow/HttpRequestParserInstrumentation.java
Show resolved
Hide resolved
mhlidd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One leftover. Thanks for the changes!
...src/main/java/datadog/trace/instrumentation/synapse3/SynapseClientWorkerInstrumentation.java
Outdated
Show resolved
Hide resolved
...et-3.0/src/main/java/datadog/trace/instrumentation/servlet3/AsyncContextInstrumentation.java
Outdated
Show resolved
Hide resolved
...ver/jetty-server-10.0/src/main/java11/datadog/trace/instrumentation/jetty10/ResetAdvice.java
Outdated
Show resolved
Hide resolved
...ver/jetty-server-10.0/src/main/java11/datadog/trace/instrumentation/jetty10/ResetAdvice.java
Outdated
Show resolved
Hide resolved
...-server-11.0/src/main/java11/datadog/trace/instrumentation/jetty11/SetContextPathAdvice.java
Outdated
Show resolved
Hide resolved
...-server-12.0/src/main/java17/datadog/trace/instrumentation/jetty12/SetContextPathAdvice.java
Show resolved
Hide resolved
.../src/main/java/datadog/trace/instrumentation/jetty70/JettyCommitResponseInstrumentation.java
Outdated
Show resolved
Hide resolved
...er-9.0.4/src/main/java/datadog/trace/instrumentation/jetty904/JettyCommitResponseHelper.java
Outdated
Show resolved
Hide resolved
ygree
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! The change looks good. A couple of suggestions:
- Remove BaseDecorator.beforeFinish(final AgentSpan span). It doesn't seem to be used anymore.
- Also, remove the extra indentation by using an early exit if there is no context. This will make the code easier to read and maintain. Additionally, your change will be more targeted.
- Remove the assignments inside the conditions. These changes will make the code easier to read and maintain.
We cannot do this because it is still used in the majority of client spans. This refactor removed the dependency in server spans |
8ca345f to
82884df
Compare
What Does This Do
This PR completes the context API migration for HTTP server spans, specifically within the
beforeFinishlifecycle.All remaining logic using
AgentSpanhas been refactored to rely on theContextAPI instead.This ensures that HTTP server request handling and span finalization are fully context-based, aligning with the ongoing context migration across the tracer.
Motivation
Migrating HTTP server spans to use context exclusively is a key step toward unifying span management under the context API.
This change enables:
beforeFinishhooks can access tracing state viaContextinstead ofAgentSpan. Refactor Severless Gateway Inferred Span #9388Additional Notes
This PR builds upon prior context migration work:
No functional behavior changes are expected for traced HTTP server requests, but all lifecycle callbacks (
beforeFinish, request propagation, etc.) now operate entirely throughContext.Contributor Checklist
type:refactor,inst:httpserver, and any additional relevant labels)solvesinstead of linking keywords when referencing issues, and assign the correct milestoneJira ticket: [PROJ-IDENT]