-
Notifications
You must be signed in to change notification settings - Fork 315
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
base: master
Are you sure you want to change the base?
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: 0c4ab54 | 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 53 metrics, 12 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.04 s) : 0, 1039839
Total [baseline] (10.831 s) : 0, 10831178
Agent [candidate] (1.032 s) : 0, 1032273
Total [candidate] (10.933 s) : 0, 10933219
section appsec
Agent [baseline] (1.208 s) : 0, 1208155
Total [baseline] (11.051 s) : 0, 11051235
Agent [candidate] (1.204 s) : 0, 1203572
Total [candidate] (10.89 s) : 0, 10890336
section iast
Agent [baseline] (1.173 s) : 0, 1172820
Total [baseline] (11.095 s) : 0, 11095049
Agent [candidate] (1.165 s) : 0, 1164921
Total [candidate] (11.131 s) : 0, 11130919
section profiling
Agent [baseline] (1.172 s) : 0, 1172148
Total [baseline] (10.905 s) : 0, 10905487
Agent [candidate] (1.179 s) : 0, 1179304
Total [candidate] (10.97 s) : 0, 10970120
gantt
title petclinic - break down per module: candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.499 ms) : 0, 1499
crashtracking [candidate] (1.489 ms) : 0, 1489
BytebuddyAgent [baseline] (709.546 ms) : 0, 709546
BytebuddyAgent [candidate] (703.741 ms) : 0, 703741
GlobalTracer [baseline] (246.544 ms) : 0, 246544
GlobalTracer [candidate] (245.502 ms) : 0, 245502
AppSec [baseline] (32.652 ms) : 0, 32652
AppSec [candidate] (32.297 ms) : 0, 32297
Debugger [baseline] (6.457 ms) : 0, 6457
Debugger [candidate] (6.36 ms) : 0, 6360
Remote Config [baseline] (683.665 µs) : 0, 684
Remote Config [candidate] (677.718 µs) : 0, 678
Telemetry [baseline] (15.288 ms) : 0, 15288
Telemetry [candidate] (14.474 ms) : 0, 14474
Flare Poller [baseline] (5.725 ms) : 0, 5725
Flare Poller [candidate] (6.446 ms) : 0, 6446
section appsec
crashtracking [baseline] (1.481 ms) : 0, 1481
crashtracking [candidate] (1.466 ms) : 0, 1466
BytebuddyAgent [baseline] (728.384 ms) : 0, 728384
BytebuddyAgent [candidate] (726.896 ms) : 0, 726896
GlobalTracer [baseline] (236.752 ms) : 0, 236752
GlobalTracer [candidate] (236.04 ms) : 0, 236040
IAST [baseline] (25.089 ms) : 0, 25089
IAST [candidate] (24.882 ms) : 0, 24882
AppSec [baseline] (176.046 ms) : 0, 176046
AppSec [candidate] (174.344 ms) : 0, 174344
Debugger [baseline] (6.018 ms) : 0, 6018
Debugger [candidate] (5.925 ms) : 0, 5925
Remote Config [baseline] (638.907 µs) : 0, 639
Remote Config [candidate] (624.313 µs) : 0, 624
Telemetry [baseline] (8.614 ms) : 0, 8614
Telemetry [candidate] (8.38 ms) : 0, 8380
Flare Poller [baseline] (3.947 ms) : 0, 3947
Flare Poller [candidate] (3.862 ms) : 0, 3862
section iast
crashtracking [baseline] (1.481 ms) : 0, 1481
crashtracking [candidate] (1.47 ms) : 0, 1470
BytebuddyAgent [baseline] (833.606 ms) : 0, 833606
BytebuddyAgent [candidate] (826.285 ms) : 0, 826285
GlobalTracer [baseline] (235.032 ms) : 0, 235032
GlobalTracer [candidate] (234.711 ms) : 0, 234711
IAST [baseline] (35.262 ms) : 0, 35262
IAST [candidate] (31.905 ms) : 0, 31905
AppSec [baseline] (26.545 ms) : 0, 26545
AppSec [candidate] (29.707 ms) : 0, 29707
Debugger [baseline] (6.195 ms) : 0, 6195
Debugger [candidate] (6.172 ms) : 0, 6172
Remote Config [baseline] (608.072 µs) : 0, 608
Remote Config [candidate] (604.406 µs) : 0, 604
Telemetry [baseline] (8.541 ms) : 0, 8541
Telemetry [candidate] (8.558 ms) : 0, 8558
Flare Poller [baseline] (4.139 ms) : 0, 4139
Flare Poller [candidate] (4.201 ms) : 0, 4201
section profiling
crashtracking [baseline] (1.467 ms) : 0, 1467
crashtracking [candidate] (1.45 ms) : 0, 1450
BytebuddyAgent [baseline] (726.125 ms) : 0, 726125
BytebuddyAgent [candidate] (730.945 ms) : 0, 730945
GlobalTracer [baseline] (219.885 ms) : 0, 219885
GlobalTracer [candidate] (221.301 ms) : 0, 221301
AppSec [baseline] (32.147 ms) : 0, 32147
AppSec [candidate] (33.301 ms) : 0, 33301
Debugger [baseline] (11.344 ms) : 0, 11344
Debugger [candidate] (9.991 ms) : 0, 9991
Remote Config [baseline] (1.485 ms) : 0, 1485
Remote Config [candidate] (2.098 ms) : 0, 2098
Telemetry [baseline] (9.963 ms) : 0, 9963
Telemetry [candidate] (10.694 ms) : 0, 10694
Flare Poller [baseline] (4.057 ms) : 0, 4057
Flare Poller [candidate] (4.112 ms) : 0, 4112
ProfilingAgent [baseline] (109.407 ms) : 0, 109407
ProfilingAgent [candidate] (109.585 ms) : 0, 109585
Profiling [baseline] (110.052 ms) : 0, 110052
Profiling [candidate] (110.205 ms) : 0, 110205
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.032 s) : 0, 1031648
Total [baseline] (8.724 s) : 0, 8724048
Agent [candidate] (1.038 s) : 0, 1038456
Total [candidate] (8.705 s) : 0, 8705303
section iast
Agent [baseline] (1.165 s) : 0, 1164984
Total [baseline] (9.438 s) : 0, 9438284
Agent [candidate] (1.165 s) : 0, 1165461
Total [candidate] (9.369 s) : 0, 9368625
gantt
title insecure-bank - break down per module: candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.466 ms) : 0, 1466
crashtracking [candidate] (1.488 ms) : 0, 1488
BytebuddyAgent [baseline] (703.841 ms) : 0, 703841
BytebuddyAgent [candidate] (709.536 ms) : 0, 709536
GlobalTracer [baseline] (244.917 ms) : 0, 244917
GlobalTracer [candidate] (245.56 ms) : 0, 245560
AppSec [baseline] (32.16 ms) : 0, 32160
AppSec [candidate] (32.346 ms) : 0, 32346
Debugger [baseline] (6.378 ms) : 0, 6378
Debugger [candidate] (6.398 ms) : 0, 6398
Remote Config [baseline] (689.018 µs) : 0, 689
Remote Config [candidate] (679.122 µs) : 0, 679
Telemetry [baseline] (13.021 ms) : 0, 13021
Telemetry [candidate] (14.993 ms) : 0, 14993
Flare Poller [baseline] (7.978 ms) : 0, 7978
Flare Poller [candidate] (6.07 ms) : 0, 6070
section iast
crashtracking [baseline] (1.492 ms) : 0, 1492
crashtracking [candidate] (1.466 ms) : 0, 1466
BytebuddyAgent [baseline] (824.368 ms) : 0, 824368
BytebuddyAgent [candidate] (826.489 ms) : 0, 826489
GlobalTracer [baseline] (235.723 ms) : 0, 235723
GlobalTracer [candidate] (235.397 ms) : 0, 235397
AppSec [baseline] (29.346 ms) : 0, 29346
AppSec [candidate] (29.808 ms) : 0, 29808
Debugger [baseline] (6.155 ms) : 0, 6155
Debugger [candidate] (6.08 ms) : 0, 6080
Remote Config [baseline] (607.911 µs) : 0, 608
Remote Config [candidate] (598.699 µs) : 0, 599
Telemetry [baseline] (8.612 ms) : 0, 8612
Telemetry [candidate] (8.507 ms) : 0, 8507
Flare Poller [baseline] (4.21 ms) : 0, 4210
Flare Poller [candidate] (4.039 ms) : 0, 4039
IAST [baseline] (33.156 ms) : 0, 33156
IAST [candidate] (31.725 ms) : 0, 31725
LoadParameters
See matching parameters
SummaryFound 3 performance improvements and 3 performance regressions! Performance is the same for 6 metrics, 12 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section baseline
no_agent (1.202 ms) : 1190, 1214
. : milestone, 1202,
iast (3.337 ms) : 3288, 3387
. : milestone, 3337,
iast_FULL (5.609 ms) : 5554, 5664
. : milestone, 5609,
iast_GLOBAL (3.598 ms) : 3532, 3664
. : milestone, 3598,
profiling (1.956 ms) : 1939, 1972
. : milestone, 1956,
tracing (1.787 ms) : 1771, 1803
. : milestone, 1787,
section candidate
no_agent (1.197 ms) : 1185, 1209
. : milestone, 1197,
iast (3.198 ms) : 3156, 3241
. : milestone, 3198,
iast_FULL (5.992 ms) : 5931, 6053
. : milestone, 5992,
iast_GLOBAL (3.619 ms) : 3566, 3671
. : milestone, 3619,
profiling (1.893 ms) : 1878, 1908
. : milestone, 1893,
tracing (1.851 ms) : 1835, 1866
. : milestone, 1851,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section baseline
no_agent (18.083 ms) : 17900, 18266
. : milestone, 18083,
appsec (19.799 ms) : 19594, 20004
. : milestone, 19799,
code_origins (18.371 ms) : 18187, 18554
. : milestone, 18371,
iast (18.526 ms) : 18338, 18714
. : milestone, 18526,
profiling (19.289 ms) : 19094, 19484
. : milestone, 19289,
tracing (18.531 ms) : 18344, 18718
. : milestone, 18531,
section candidate
no_agent (18.273 ms) : 18086, 18459
. : milestone, 18273,
appsec (19.605 ms) : 19403, 19808
. : milestone, 19605,
code_origins (18.431 ms) : 18246, 18616
. : milestone, 18431,
iast (18.394 ms) : 18207, 18581
. : milestone, 18394,
profiling (20.145 ms) : 19945, 20344
. : milestone, 20145,
tracing (17.596 ms) : 17420, 17771
. : milestone, 17596,
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~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section baseline
no_agent (15.672 s) : 15672000, 15672000
. : milestone, 15672000,
appsec (15.011 s) : 15011000, 15011000
. : milestone, 15011000,
iast (18.986 s) : 18986000, 18986000
. : milestone, 18986000,
iast_GLOBAL (18.323 s) : 18323000, 18323000
. : milestone, 18323000,
profiling (15.287 s) : 15287000, 15287000
. : milestone, 15287000,
tracing (15.137 s) : 15137000, 15137000
. : milestone, 15137000,
section candidate
no_agent (15.558 s) : 15558000, 15558000
. : milestone, 15558000,
appsec (14.893 s) : 14893000, 14893000
. : milestone, 14893000,
iast (18.497 s) : 18497000, 18497000
. : milestone, 18497000,
iast_GLOBAL (17.804 s) : 17804000, 17804000
. : milestone, 17804000,
profiling (15.343 s) : 15343000, 15343000
. : milestone, 15343000,
tracing (15.287 s) : 15287000, 15287000
. : milestone, 15287000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.53.0-SNAPSHOT~0c4ab54349, baseline=1.55.0-SNAPSHOT~9b91826873
dateFormat X
axisFormat %s
section baseline
no_agent (1.476 ms) : 1465, 1488
. : milestone, 1476,
appsec (3.712 ms) : 3493, 3931
. : milestone, 3712,
iast (2.216 ms) : 2152, 2279
. : milestone, 2216,
iast_GLOBAL (2.261 ms) : 2197, 2325
. : milestone, 2261,
profiling (2.08 ms) : 2026, 2133
. : milestone, 2080,
tracing (2.031 ms) : 1981, 2081
. : milestone, 2031,
section candidate
no_agent (1.475 ms) : 1463, 1486
. : milestone, 1475,
appsec (3.719 ms) : 3502, 3937
. : milestone, 3719,
iast (2.212 ms) : 2148, 2276
. : milestone, 2212,
iast_GLOBAL (2.243 ms) : 2179, 2307
. : milestone, 2243,
profiling (2.08 ms) : 2027, 2133
. : milestone, 2080,
tracing (2.041 ms) : 1991, 2091
. : milestone, 2041,
|
| public AgentSpan beforeFinish(final AgentSpan span) { | ||
| return span; | ||
| } |
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.
Is that the only one blocker? Because the WebSocketDecorator is calling the empty BaseDecorator.beforeFinish() and has no override... So technically, the call is doing nothing :/
So we can move it from BaseDecorator to WebSocketDecorator and migrate it in a second pass.
@amarziali What's the effort to migrate the WebSocket instrumentation to context rather than span?
...entation/cxf-2.1/src/main/java/datadog/trace/instrumentation/cxf/InvokerInstrumentation.java
Outdated
Show resolved
Hide resolved
...ain/java/datadog/trace/instrumentation/grizzlyhttp232/DefaultFilterChainInstrumentation.java
Outdated
Show resolved
Hide resolved
...zly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java
Outdated
Show resolved
Hide resolved
...zly-http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/FilterAdvice.java
Show resolved
Hide resolved
...http-2.3.20/src/main/java/datadog/trace/instrumentation/grizzlyhttp232/GrizzlyDecorator.java
Outdated
Show resolved
Hide resolved
...t-1.1/src/main/java/datadog/trace/instrumentation/jaxrs/v1/JaxRsClientV1Instrumentation.java
Outdated
Show resolved
Hide resolved
| @@ -53,42 +55,58 @@ public void methodAdvice(MethodTransformer transformer) { | |||
|
|
|||
| static class HandleAdvice { | |||
| @Advice.OnMethodEnter(suppress = Throwable.class) | |||
| static AgentScope onEnter( | |||
| static ContextScope onEnter( | |||
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.
📝 notes: Note for myself. Time boxed the review to 1h and paused here for Today
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.
I miss baggage about Jetty instrumentation but mixing main context and dispatch span feels different than the original behavior. Did I miss something?
...ver-7.0/src/main/java/datadog/trace/instrumentation/jetty70/ServerHandleInstrumentation.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/jetty9/JettyCommitResponseInstrumentation.java
Outdated
Show resolved
Hide resolved
...rver-9.0/src/main/java/datadog/trace/instrumentation/jetty9/ServerHandleInstrumentation.java
Outdated
Show resolved
Hide resolved
...0/src/main/java_jetty10/datadog/trace/instrumentation/jetty10/JettyCommitResponseHelper.java
Outdated
Show resolved
Hide resolved
...rver-9.0/src/main/java_jetty10/datadog/trace/instrumentation/jetty10/ServerHandleAdvice.java
Outdated
Show resolved
Hide resolved
...src/main/java_jetty904/datadog/trace/instrumentation/jetty904/JettyCommitResponseHelper.java
Outdated
Show resolved
Hide resolved
...0/src/main/java_jetty93/datadog/trace/instrumentation/jetty93/JettyCommitResponseHelper.java
Outdated
Show resolved
Hide resolved
...c/main/java_jetty9421/datadog/trace/instrumentation/jetty9421/JettyCommitResponseHelper.java
Outdated
Show resolved
Hide resolved
|
System Tests are fixed here - DataDog/system-tests#5430 |
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.
👋 I didn't get the chance to fully review all files but I do have a concern.
Whenever scope.context() is called, we may need to make sure that the scope used is a ContextScope. If it is invoked on an AgentScope (like it is in many files now), we will get an AgentSpan back, which will lead to the wrong implementation of beforeFinish being called and the InferredProxySpan not actually getting finished.
Curious to what @PerfectSlayer and @mcculls think about this.
...tp-10.0/src/main/java/datadog/trace/instrumentation/akkahttp/DatadogAsyncHandlerWrapper.java
Outdated
Show resolved
Hide resolved
...instrumentation/axway-api/src/main/java/datadog/trace/instrumentation/axway/StateAdvice.java
Outdated
Show resolved
Hide resolved
...umentation/axway-api/src/main/java/datadog/trace/instrumentation/axway/HTTPPluginAdvice.java
Outdated
Show resolved
Hide resolved
| if (throwable != null) { | ||
| DECORATE.onError(span, throwable); | ||
| DECORATE.beforeFinish(span); | ||
| DECORATE.beforeFinish(scope.context()); |
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.
Same thing here, may need to migrate to ContextScope.
What Does This Do
Finishes context API migration in regards to
beforeFinishusing context instead of spanRefactors everything to use context instead of span across requests
Motivation
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any usefull labelsclose,fixor any linking keywords when referencing an issue.Use
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]