-
Notifications
You must be signed in to change notification settings - Fork 291
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
Prevent AppSec context from being closed more than once on partial flush #7059
Conversation
e080203
to
4f31ab5
Compare
2de54da
to
0a1311d
Compare
@@ -240,11 +240,33 @@ PropagationTags.Factory getPropagationTagsFactory() { | |||
return propagationTagsFactory; | |||
} | |||
|
|||
/** | |||
* Called when a root span is finished before it is serialized. This is might be called multiple |
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 catch!
We had some hooks in `CoreTracer.write` meant to be run whenever a root span is finished. However, they were effectively called not just when the root span finished, but also whenever a partial flush on a child span was performed. This ended up calling the hooks multiple times, and earlier than expected.
11f512d
to
81eb977
Compare
BenchmarksStartupParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 16 unstable metrics.
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.056 s) : 0, 1056490
Total [baseline] (10.353 s) : 0, 10353263
Agent [candidate] (1.063 s) : 0, 1063102
Total [candidate] (10.397 s) : 0, 10396759
section appsec
Agent [baseline] (1.172 s) : 0, 1171867
Total [baseline] (10.44 s) : 0, 10440245
Agent [candidate] (1.174 s) : 0, 1174481
Total [candidate] (10.491 s) : 0, 10491186
section iast
Agent [baseline] (1.182 s) : 0, 1182140
Total [baseline] (10.813 s) : 0, 10812561
Agent [candidate] (1.188 s) : 0, 1187581
Total [candidate] (10.771 s) : 0, 10771140
section profiling
Agent [baseline] (1.256 s) : 0, 1255941
Total [baseline] (10.617 s) : 0, 10616567
Agent [candidate] (1.262 s) : 0, 1261594
Total [candidate] (10.592 s) : 0, 10592224
gantt
title petclinic - break down per module: candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (652.29 ms) : 0, 652290
BytebuddyAgent [candidate] (655.999 ms) : 0, 655999
GlobalTracer [baseline] (312.348 ms) : 0, 312348
GlobalTracer [candidate] (314.21 ms) : 0, 314210
AppSec [baseline] (49.37 ms) : 0, 49370
AppSec [candidate] (50.014 ms) : 0, 50014
Remote Config [baseline] (663.391 µs) : 0, 663
Remote Config [candidate] (681.636 µs) : 0, 682
Telemetry [baseline] (7.549 ms) : 0, 7549
Telemetry [candidate] (7.674 ms) : 0, 7674
section appsec
BytebuddyAgent [baseline] (673.077 ms) : 0, 673077
BytebuddyAgent [candidate] (674.143 ms) : 0, 674143
GlobalTracer [baseline] (295.006 ms) : 0, 295006
GlobalTracer [candidate] (295.613 ms) : 0, 295613
AppSec [baseline] (152.382 ms) : 0, 152382
AppSec [candidate] (152.492 ms) : 0, 152492
IAST [baseline] (18.666 ms) : 0, 18666
IAST [candidate] (18.836 ms) : 0, 18836
Remote Config [baseline] (625.216 µs) : 0, 625
Remote Config [candidate] (630.448 µs) : 0, 630
Telemetry [baseline] (7.138 ms) : 0, 7138
Telemetry [candidate] (7.761 ms) : 0, 7761
section iast
BytebuddyAgent [baseline] (775.875 ms) : 0, 775875
BytebuddyAgent [candidate] (778.337 ms) : 0, 778337
GlobalTracer [baseline] (291.625 ms) : 0, 291625
GlobalTracer [candidate] (292.338 ms) : 0, 292338
AppSec [baseline] (48.754 ms) : 0, 48754
AppSec [candidate] (48.91 ms) : 0, 48910
IAST [baseline] (23.723 ms) : 0, 23723
IAST [candidate] (25.692 ms) : 0, 25692
Remote Config [baseline] (607.275 µs) : 0, 607
Remote Config [candidate] (628.842 µs) : 0, 629
Telemetry [baseline] (7.299 ms) : 0, 7299
Telemetry [candidate] (7.267 ms) : 0, 7267
section profiling
BytebuddyAgent [baseline] (661.148 ms) : 0, 661148
BytebuddyAgent [candidate] (664.156 ms) : 0, 664156
GlobalTracer [baseline] (384.048 ms) : 0, 384048
GlobalTracer [candidate] (386.411 ms) : 0, 386411
AppSec [baseline] (50.325 ms) : 0, 50325
AppSec [candidate] (50.955 ms) : 0, 50955
Remote Config [baseline] (856.374 µs) : 0, 856
Remote Config [candidate] (841.978 µs) : 0, 842
Telemetry [baseline] (7.415 ms) : 0, 7415
Telemetry [candidate] (7.522 ms) : 0, 7522
ProfilingAgent [baseline] (95.651 ms) : 0, 95651
ProfilingAgent [candidate] (94.943 ms) : 0, 94943
Profiling [baseline] (95.676 ms) : 0, 95676
Profiling [candidate] (94.968 ms) : 0, 94968
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.061 s) : 0, 1060908
Total [baseline] (8.557 s) : 0, 8557168
Agent [candidate] (1.053 s) : 0, 1053342
Total [candidate] (8.523 s) : 0, 8522703
section iast
Agent [baseline] (1.184 s) : 0, 1184169
Total [baseline] (9.003 s) : 0, 9002874
Agent [candidate] (1.183 s) : 0, 1182625
Total [candidate] (9.003 s) : 0, 9002672
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.202 s) : 0, 1201897
Total [baseline] (9.015 s) : 0, 9015336
Agent [candidate] (1.182 s) : 0, 1182361
Total [candidate] (8.989 s) : 0, 8988846
section iast_TELEMETRY_OFF
Agent [baseline] (1.192 s) : 0, 1191651
Total [baseline] (8.996 s) : 0, 8995731
Agent [candidate] (1.19 s) : 0, 1189581
Total [candidate] (9.061 s) : 0, 9061298
gantt
title insecure-bank - break down per module: candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (654.844 ms) : 0, 654844
BytebuddyAgent [candidate] (650.037 ms) : 0, 650037
GlobalTracer [baseline] (313.392 ms) : 0, 313392
GlobalTracer [candidate] (311.295 ms) : 0, 311295
AppSec [baseline] (50.017 ms) : 0, 50017
AppSec [candidate] (49.519 ms) : 0, 49519
Remote Config [baseline] (658.569 µs) : 0, 659
Remote Config [candidate] (668.966 µs) : 0, 669
Telemetry [baseline] (7.574 ms) : 0, 7574
Telemetry [candidate] (7.608 ms) : 0, 7608
section iast
BytebuddyAgent [baseline] (776.8 ms) : 0, 776800
BytebuddyAgent [candidate] (774.803 ms) : 0, 774803
GlobalTracer [baseline] (292.194 ms) : 0, 292194
GlobalTracer [candidate] (291.05 ms) : 0, 291050
AppSec [baseline] (49.958 ms) : 0, 49958
AppSec [candidate] (49.84 ms) : 0, 49840
IAST [baseline] (22.213 ms) : 0, 22213
IAST [candidate] (22.471 ms) : 0, 22471
Remote Config [baseline] (587.887 µs) : 0, 588
Remote Config [candidate] (605.654 µs) : 0, 606
Telemetry [baseline] (8.073 ms) : 0, 8073
Telemetry [candidate] (9.684 ms) : 0, 9684
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (788.356 ms) : 0, 788356
BytebuddyAgent [candidate] (775.472 ms) : 0, 775472
GlobalTracer [baseline] (296.178 ms) : 0, 296178
GlobalTracer [candidate] (291.954 ms) : 0, 291954
AppSec [baseline] (50.348 ms) : 0, 50348
AppSec [candidate] (46.825 ms) : 0, 46825
IAST [baseline] (23.354 ms) : 0, 23354
IAST [candidate] (25.787 ms) : 0, 25787
Remote Config [baseline] (597.449 µs) : 0, 597
Remote Config [candidate] (622.663 µs) : 0, 623
Telemetry [baseline] (8.162 ms) : 0, 8162
Telemetry [candidate] (7.359 ms) : 0, 7359
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (780.981 ms) : 0, 780981
BytebuddyAgent [candidate] (779.653 ms) : 0, 779653
GlobalTracer [baseline] (294.814 ms) : 0, 294814
GlobalTracer [candidate] (293.523 ms) : 0, 293523
AppSec [baseline] (47.799 ms) : 0, 47799
AppSec [candidate] (49.953 ms) : 0, 49953
IAST [baseline] (26.098 ms) : 0, 26098
IAST [candidate] (23.869 ms) : 0, 23869
Remote Config [baseline] (661.703 µs) : 0, 662
Remote Config [candidate] (629.975 µs) : 0, 630
Telemetry [baseline] (6.549 ms) : 0, 6549
Telemetry [candidate] (7.371 ms) : 0, 7371
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 13 metrics, 15 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section baseline
no_agent (366.905 µs) : 347, 387
. : milestone, 367,
iast (477.038 µs) : 456, 498
. : milestone, 477,
iast_FULL (548.933 µs) : 528, 570
. : milestone, 549,
iast_GLOBAL (505.025 µs) : 483, 527
. : milestone, 505,
iast_HARDCODED_SECRET_DISABLED (480.89 µs) : 460, 502
. : milestone, 481,
iast_INACTIVE (460.114 µs) : 439, 481
. : milestone, 460,
iast_TELEMETRY_OFF (472.182 µs) : 451, 493
. : milestone, 472,
tracing (456.086 µs) : 435, 477
. : milestone, 456,
section candidate
no_agent (372.278 µs) : 352, 393
. : milestone, 372,
iast (485.2 µs) : 464, 507
. : milestone, 485,
iast_FULL (549.566 µs) : 528, 571
. : milestone, 550,
iast_GLOBAL (513.158 µs) : 490, 536
. : milestone, 513,
iast_HARDCODED_SECRET_DISABLED (484.994 µs) : 464, 506
. : milestone, 485,
iast_INACTIVE (449.912 µs) : 429, 471
. : milestone, 450,
iast_TELEMETRY_OFF (473.88 µs) : 452, 496
. : milestone, 474,
tracing (439.673 µs) : 419, 460
. : milestone, 440,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section baseline
no_agent (1.341 ms) : 1321, 1362
. : milestone, 1341,
appsec (1.729 ms) : 1706, 1753
. : milestone, 1729,
appsec_no_iast (1.695 ms) : 1671, 1718
. : milestone, 1695,
iast (1.493 ms) : 1470, 1516
. : milestone, 1493,
profiling (1.503 ms) : 1479, 1526
. : milestone, 1503,
tracing (1.465 ms) : 1441, 1489
. : milestone, 1465,
section candidate
no_agent (1.344 ms) : 1325, 1363
. : milestone, 1344,
appsec (1.699 ms) : 1674, 1724
. : milestone, 1699,
appsec_no_iast (1.708 ms) : 1683, 1733
. : milestone, 1708,
iast (1.472 ms) : 1447, 1496
. : milestone, 1472,
profiling (1.539 ms) : 1514, 1564
. : milestone, 1539,
tracing (1.466 ms) : 1442, 1490
. : milestone, 1466,
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.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section baseline
no_agent (15.418 s) : 15418000, 15418000
. : milestone, 15418000,
appsec (14.988 s) : 14988000, 14988000
. : milestone, 14988000,
iast (18.783 s) : 18783000, 18783000
. : milestone, 18783000,
iast_GLOBAL (17.811 s) : 17811000, 17811000
. : milestone, 17811000,
profiling (15.102 s) : 15102000, 15102000
. : milestone, 15102000,
tracing (15.336 s) : 15336000, 15336000
. : milestone, 15336000,
section candidate
no_agent (15.346 s) : 15346000, 15346000
. : milestone, 15346000,
appsec (15.14 s) : 15140000, 15140000
. : milestone, 15140000,
iast (18.889 s) : 18889000, 18889000
. : milestone, 18889000,
iast_GLOBAL (17.879 s) : 17879000, 17879000
. : milestone, 17879000,
profiling (15.708 s) : 15708000, 15708000
. : milestone, 15708000,
tracing (14.953 s) : 14953000, 14953000
. : milestone, 14953000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.35.0-SNAPSHOT~81eb977eeb, baseline=1.35.0-SNAPSHOT~bd6b34d283
dateFormat X
axisFormat %s
section baseline
no_agent (1.465 ms) : 1453, 1476
. : milestone, 1465,
appsec (2.19 ms) : 2156, 2224
. : milestone, 2190,
iast (1.964 ms) : 1922, 2005
. : milestone, 1964,
iast_GLOBAL (1.992 ms) : 1951, 2033
. : milestone, 1992,
profiling (1.837 ms) : 1804, 1871
. : milestone, 1837,
tracing (1.813 ms) : 1781, 1844
. : milestone, 1813,
section candidate
no_agent (1.458 ms) : 1446, 1469
. : milestone, 1458,
appsec (2.186 ms) : 2152, 2219
. : milestone, 2186,
iast (1.95 ms) : 1910, 1990
. : milestone, 1950,
iast_GLOBAL (1.996 ms) : 1954, 2037
. : milestone, 1996,
profiling (1.829 ms) : 1795, 1862
. : milestone, 1829,
tracing (1.817 ms) : 1784, 1849
. : milestone, 1817,
|
What Does This Do
Ensure that AppSec hooks for root span finished run only once.
Motivation
We had some hooks in
CoreTracer.write
meant to be run whenever a root span is finished. However, they were effectively called not just when the root span finished, but also whenever a partial flush on a child span was performed. This ended up calling the hooks multiple teams, and earlier than expected.When
DD_APPSEC_ENABLED=true
, this led toWAF object had not been closed
warnings whenever a partial flush was triggered and the root span was not finished yet.Reproducing the issue is easier when setting
-Ddd.trace.partial.flush.min.spans=1
.Additional Notes
Jira ticket: APPSEC-53203