-
Notifications
You must be signed in to change notification settings - Fork 300
Rework Kotlin coroutines instrumentation around coroutine context #8774
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
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 59 metrics, 12 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.023 s) : 0, 1023211
Total [baseline] (10.479 s) : 0, 10479305
Agent [candidate] (1.018 s) : 0, 1018140
Total [candidate] (10.494 s) : 0, 10493633
section appsec
Agent [baseline] (1.157 s) : 0, 1157173
Total [baseline] (10.653 s) : 0, 10653479
Agent [candidate] (1.161 s) : 0, 1160889
Total [candidate] (10.634 s) : 0, 10634415
section iast
Agent [baseline] (1.147 s) : 0, 1146691
Total [baseline] (10.867 s) : 0, 10867323
Agent [candidate] (1.146 s) : 0, 1146259
Total [candidate] (10.93 s) : 0, 10929681
section profiling
Agent [baseline] (1.281 s) : 0, 1280534
Total [baseline] (10.898 s) : 0, 10898256
Agent [candidate] (1.28 s) : 0, 1279562
Total [candidate] (10.807 s) : 0, 10807447
gantt
title petclinic - break down per module: candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (685.953 ms) : 0, 685953
BytebuddyAgent [candidate] (681.773 ms) : 0, 681773
GlobalTracer [baseline] (240.971 ms) : 0, 240971
GlobalTracer [candidate] (239.794 ms) : 0, 239794
AppSec [baseline] (54.627 ms) : 0, 54627
AppSec [candidate] (54.479 ms) : 0, 54479
Debugger [baseline] (8.962 ms) : 0, 8962
Debugger [candidate] (8.192 ms) : 0, 8192
Remote Config [baseline] (691.447 µs) : 0, 691
Remote Config [candidate] (694.489 µs) : 0, 694
Telemetry [baseline] (8.343 ms) : 0, 8343
Telemetry [candidate] (9.696 ms) : 0, 9696
section appsec
BytebuddyAgent [baseline] (698.813 ms) : 0, 698813
BytebuddyAgent [candidate] (700.179 ms) : 0, 700179
GlobalTracer [baseline] (235.887 ms) : 0, 235887
GlobalTracer [candidate] (236.585 ms) : 0, 236585
AppSec [baseline] (174.151 ms) : 0, 174151
AppSec [candidate] (175.858 ms) : 0, 175858
Debugger [baseline] (5.943 ms) : 0, 5943
Debugger [candidate] (5.957 ms) : 0, 5957
Remote Config [baseline] (618.861 µs) : 0, 619
Remote Config [candidate] (631.117 µs) : 0, 631
Telemetry [baseline] (7.411 ms) : 0, 7411
Telemetry [candidate] (7.418 ms) : 0, 7418
IAST [baseline] (21.673 ms) : 0, 21673
IAST [candidate] (21.635 ms) : 0, 21635
section iast
BytebuddyAgent [baseline] (800.43 ms) : 0, 800430
BytebuddyAgent [candidate] (800.101 ms) : 0, 800101
GlobalTracer [baseline] (230.077 ms) : 0, 230077
GlobalTracer [candidate] (230.244 ms) : 0, 230244
AppSec [baseline] (52.0 ms) : 0, 52000
AppSec [candidate] (48.499 ms) : 0, 48499
Debugger [baseline] (5.902 ms) : 0, 5902
Debugger [candidate] (5.859 ms) : 0, 5859
Remote Config [baseline] (594.637 µs) : 0, 595
Remote Config [candidate] (591.026 µs) : 0, 591
Telemetry [baseline] (7.87 ms) : 0, 7870
Telemetry [candidate] (7.879 ms) : 0, 7879
IAST [baseline] (26.435 ms) : 0, 26435
IAST [candidate] (29.686 ms) : 0, 29686
section profiling
BytebuddyAgent [baseline] (673.276 ms) : 0, 673276
BytebuddyAgent [candidate] (672.336 ms) : 0, 672336
GlobalTracer [baseline] (378.533 ms) : 0, 378533
GlobalTracer [candidate] (378.532 ms) : 0, 378532
AppSec [baseline] (54.242 ms) : 0, 54242
AppSec [candidate] (53.949 ms) : 0, 53949
Debugger [baseline] (6.085 ms) : 0, 6085
Debugger [candidate] (6.165 ms) : 0, 6165
Remote Config [baseline] (645.496 µs) : 0, 645
Remote Config [candidate] (651.493 µs) : 0, 651
Telemetry [baseline] (8.089 ms) : 0, 8089
Telemetry [candidate] (8.121 ms) : 0, 8121
ProfilingAgent [baseline] (109.069 ms) : 0, 109069
ProfilingAgent [candidate] (109.283 ms) : 0, 109283
Profiling [baseline] (109.094 ms) : 0, 109094
Profiling [candidate] (109.309 ms) : 0, 109309
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.029 s) : 0, 1028787
Total [baseline] (8.633 s) : 0, 8633479
Agent [candidate] (1.019 s) : 0, 1018982
Total [candidate] (8.645 s) : 0, 8645096
section iast
Agent [baseline] (1.146 s) : 0, 1145648
Total [baseline] (9.188 s) : 0, 9188155
Agent [candidate] (1.147 s) : 0, 1146884
Total [candidate] (9.2 s) : 0, 9199738
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.147 s) : 0, 1147246
Total [baseline] (9.227 s) : 0, 9227232
Agent [candidate] (1.153 s) : 0, 1153361
Total [candidate] (9.205 s) : 0, 9205317
section iast_TELEMETRY_OFF
Agent [baseline] (1.161 s) : 0, 1161068
Total [baseline] (9.266 s) : 0, 9266352
Agent [candidate] (1.144 s) : 0, 1143715
Total [candidate] (9.196 s) : 0, 9196216
gantt
title insecure-bank - break down per module: candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (688.943 ms) : 0, 688943
BytebuddyAgent [candidate] (680.45 ms) : 0, 680450
GlobalTracer [baseline] (241.699 ms) : 0, 241699
GlobalTracer [candidate] (239.245 ms) : 0, 239245
AppSec [baseline] (55.7 ms) : 0, 55700
AppSec [candidate] (54.81 ms) : 0, 54810
Debugger [baseline] (8.311 ms) : 0, 8311
Debugger [candidate] (10.569 ms) : 0, 10569
Remote Config [baseline] (694.674 µs) : 0, 695
Remote Config [candidate] (686.604 µs) : 0, 687
Telemetry [baseline] (9.774 ms) : 0, 9774
Telemetry [candidate] (9.684 ms) : 0, 9684
section iast
BytebuddyAgent [baseline] (799.644 ms) : 0, 799644
BytebuddyAgent [candidate] (800.234 ms) : 0, 800234
GlobalTracer [baseline] (229.688 ms) : 0, 229688
GlobalTracer [candidate] (230.279 ms) : 0, 230279
AppSec [baseline] (50.279 ms) : 0, 50279
AppSec [candidate] (51.079 ms) : 0, 51079
Debugger [baseline] (5.907 ms) : 0, 5907
Debugger [candidate] (5.906 ms) : 0, 5906
Remote Config [baseline] (584.316 µs) : 0, 584
Remote Config [candidate] (606.098 µs) : 0, 606
Telemetry [baseline] (7.845 ms) : 0, 7845
Telemetry [candidate] (7.906 ms) : 0, 7906
IAST [baseline] (28.171 ms) : 0, 28171
IAST [candidate] (24.322 ms) : 0, 24322
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (801.014 ms) : 0, 801014
BytebuddyAgent [candidate] (804.888 ms) : 0, 804888
GlobalTracer [baseline] (230.219 ms) : 0, 230219
GlobalTracer [candidate] (231.627 ms) : 0, 231627
AppSec [baseline] (48.567 ms) : 0, 48567
AppSec [candidate] (48.688 ms) : 0, 48688
Debugger [baseline] (5.853 ms) : 0, 5853
Debugger [candidate] (5.941 ms) : 0, 5941
Remote Config [baseline] (579.168 µs) : 0, 579
Remote Config [candidate] (586.448 µs) : 0, 586
Telemetry [baseline] (7.843 ms) : 0, 7843
Telemetry [candidate] (8.011 ms) : 0, 8011
IAST [baseline] (29.696 ms) : 0, 29696
IAST [candidate] (30.084 ms) : 0, 30084
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (810.262 ms) : 0, 810262
BytebuddyAgent [candidate] (796.787 ms) : 0, 796787
GlobalTracer [baseline] (232.98 ms) : 0, 232980
GlobalTracer [candidate] (230.833 ms) : 0, 230833
AppSec [baseline] (54.19 ms) : 0, 54190
AppSec [candidate] (53.319 ms) : 0, 53319
Debugger [baseline] (6.083 ms) : 0, 6083
Debugger [candidate] (5.991 ms) : 0, 5991
Remote Config [baseline] (617.799 µs) : 0, 618
Remote Config [candidate] (608.084 µs) : 0, 608
Telemetry [baseline] (7.952 ms) : 0, 7952
Telemetry [candidate] (7.858 ms) : 0, 7858
IAST [baseline] (25.156 ms) : 0, 25156
IAST [candidate] (24.847 ms) : 0, 24847
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 18 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section baseline
no_agent (381.245 µs) : 362, 401
. : milestone, 381,
iast (530.203 µs) : 507, 553
. : milestone, 530,
iast_FULL (724.13 µs) : 702, 746
. : milestone, 724,
iast_GLOBAL (553.688 µs) : 532, 575
. : milestone, 554,
iast_HARDCODED_SECRET_DISABLED (516.875 µs) : 494, 539
. : milestone, 517,
iast_INACTIVE (455.373 µs) : 434, 476
. : milestone, 455,
iast_TELEMETRY_OFF (510.831 µs) : 487, 534
. : milestone, 511,
tracing (463.084 µs) : 441, 485
. : milestone, 463,
section candidate
no_agent (385.554 µs) : 366, 405
. : milestone, 386,
iast (513.126 µs) : 491, 535
. : milestone, 513,
iast_FULL (740.995 µs) : 719, 763
. : milestone, 741,
iast_GLOBAL (562.872 µs) : 540, 585
. : milestone, 563,
iast_HARDCODED_SECRET_DISABLED (522.818 µs) : 500, 546
. : milestone, 523,
iast_INACTIVE (465.449 µs) : 443, 488
. : milestone, 465,
iast_TELEMETRY_OFF (510.316 µs) : 487, 533
. : milestone, 510,
tracing (457.472 µs) : 435, 480
. : milestone, 457,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section baseline
no_agent (1.359 ms) : 1340, 1378
. : milestone, 1359,
appsec (1.742 ms) : 1718, 1765
. : milestone, 1742,
appsec_no_iast (1.732 ms) : 1709, 1754
. : milestone, 1732,
code_origins (1.643 ms) : 1617, 1669
. : milestone, 1643,
iast (1.509 ms) : 1485, 1533
. : milestone, 1509,
profiling (1.521 ms) : 1496, 1546
. : milestone, 1521,
tracing (1.484 ms) : 1459, 1509
. : milestone, 1484,
section candidate
no_agent (1.366 ms) : 1347, 1385
. : milestone, 1366,
appsec (1.749 ms) : 1726, 1773
. : milestone, 1749,
appsec_no_iast (1.708 ms) : 1684, 1732
. : milestone, 1708,
code_origins (1.68 ms) : 1652, 1708
. : milestone, 1680,
iast (1.52 ms) : 1497, 1544
. : milestone, 1520,
profiling (1.527 ms) : 1503, 1550
. : milestone, 1527,
tracing (1.507 ms) : 1482, 1532
. : milestone, 1507,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section baseline
no_agent (15.417 s) : 15417000, 15417000
. : milestone, 15417000,
appsec (15.092 s) : 15092000, 15092000
. : milestone, 15092000,
iast (19.075 s) : 19075000, 19075000
. : milestone, 19075000,
iast_GLOBAL (18.188 s) : 18188000, 18188000
. : milestone, 18188000,
profiling (15.652 s) : 15652000, 15652000
. : milestone, 15652000,
tracing (14.921 s) : 14921000, 14921000
. : milestone, 14921000,
section candidate
no_agent (14.962 s) : 14962000, 14962000
. : milestone, 14962000,
appsec (15.146 s) : 15146000, 15146000
. : milestone, 15146000,
iast (18.987 s) : 18987000, 18987000
. : milestone, 18987000,
iast_GLOBAL (18.003 s) : 18003000, 18003000
. : milestone, 18003000,
profiling (15.502 s) : 15502000, 15502000
. : milestone, 15502000,
tracing (15.045 s) : 15045000, 15045000
. : milestone, 15045000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.50.0-SNAPSHOT~91445aea2f, baseline=1.50.0-SNAPSHOT~f494c33b01
dateFormat X
axisFormat %s
section baseline
no_agent (1.483 ms) : 1471, 1495
. : milestone, 1483,
appsec (2.418 ms) : 2368, 2467
. : milestone, 2418,
iast (2.202 ms) : 2140, 2264
. : milestone, 2202,
iast_GLOBAL (2.233 ms) : 2171, 2295
. : milestone, 2233,
profiling (2.05 ms) : 2000, 2100
. : milestone, 2050,
tracing (2.033 ms) : 1984, 2081
. : milestone, 2033,
section candidate
no_agent (1.478 ms) : 1467, 1490
. : milestone, 1478,
appsec (2.418 ms) : 2369, 2468
. : milestone, 2418,
iast (2.204 ms) : 2142, 2266
. : milestone, 2204,
iast_GLOBAL (2.248 ms) : 2185, 2311
. : milestone, 2248,
profiling (2.041 ms) : 1992, 2090
. : milestone, 2041,
tracing (2.028 ms) : 1980, 2076
. : milestone, 2028,
|
a77d8bd
to
06b989f
Compare
48b5305
to
37ba1f6
Compare
As an added benefit, this approach does not require field injection
37ba1f6
to
91445ae
Compare
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.
This is a great contribution. Much cleaner than before. Thanks also for the detailed description
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.
Nice improvement! 👍
What Does This Do
The previous approach associated the scope state with the job (coroutine) instance using field-injection. However this doesn't work when the coroutine instance might be recreated or wrapped by something else.
This new approach creates a
DatadogThreadContextElement
for every coroutine context created. The scope state is then lazily captured within this element: either after non-lazy coroutines are constructed, when lazy coroutines start, or failing that when the element is first used to update the thread context.At the same time it captures the active span using a continuation to avoid the trace from completing before the coroutine is complete. Note there is no need to (re)activate the continuation when switching contexts because we have already captured the scope state.
Motivation
This simpler instrumentation will be easier to move over to the new
Context
APIThis also fixes the scenario described in https://github.com/arun-rama/KotlinCoroutineTracingIssueRepro/tree/main
Additional Notes
As an added benefit, this approach does not require field injection
Contributor Checklist
type:
and (comp:
orinst:
) labels in addition to any usefull labelsclose
,fix
or any linking keywords when referencing an issue.Use
solves
instead, and assign the PR milestone to the issueJira ticket: AIDM-602