Skip to content
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

Reduce scope listener API #7296

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Conversation

PerfectSlayer
Copy link
Contributor

@PerfectSlayer PerfectSlayer commented Jul 9, 2024

What Does This Do

This PR reduces the API of the ExtendedScopeListener.

It also replaces the implementation of the LogContextScopeListener to use the common CorrelationIdentifier that already support 128-bit TID correlation.

Motivation

Limit the internal API to what’s needed.

Additional Notes

Now, only CWS-TLS needs the ExtendedScopeListener.
I kept it for performance reason as it needs ID using the long form.

Jira ticket: [PROJ-IDENT]

@PerfectSlayer PerfectSlayer added comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring labels Jul 9, 2024
@pr-commenter
Copy link

pr-commenter bot commented Jul 9, 2024

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/refactor-scope-listener
git_commit_date 1721038044 1721049769
git_commit_sha f88def8 086ab60
release_version 1.38.0-SNAPSHOT~f88def8618 1.38.0-SNAPSHOT~086ab609b9
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1721052254 1721052254
ci_job_id 572307937 572307937
ci_pipeline_id 39150443 39150443
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
module Agent Agent
parent None None
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 54 metrics, 9 unstable metrics.

Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.062 s) : 0, 1062019
Total [baseline] (8.503 s) : 0, 8502727
Agent [candidate] (1.074 s) : 0, 1074111
Total [candidate] (8.516 s) : 0, 8515702
section iast
Agent [baseline] (1.17 s) : 0, 1169730
Total [baseline] (8.947 s) : 0, 8946543
Agent [candidate] (1.171 s) : 0, 1171176
Total [candidate] (8.921 s) : 0, 8920595
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.183 s) : 0, 1182881
Total [baseline] (8.943 s) : 0, 8943053
Agent [candidate] (1.17 s) : 0, 1170336
Total [candidate] (8.909 s) : 0, 8908661
section iast_TELEMETRY_OFF
Agent [baseline] (1.176 s) : 0, 1175792
Total [baseline] (8.943 s) : 0, 8942718
Agent [candidate] (1.166 s) : 0, 1166214
Total [candidate] (8.937 s) : 0, 8937104
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.062 s -
Agent iast 1.17 s 107.71 ms (10.1%)
Agent iast_HARDCODED_SECRET_DISABLED 1.183 s 120.862 ms (11.4%)
Agent iast_TELEMETRY_OFF 1.176 s 113.772 ms (10.7%)
Total tracing 8.503 s -
Total iast 8.947 s 443.816 ms (5.2%)
Total iast_HARDCODED_SECRET_DISABLED 8.943 s 440.326 ms (5.2%)
Total iast_TELEMETRY_OFF 8.943 s 439.991 ms (5.2%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.074 s -
Agent iast 1.171 s 97.065 ms (9.0%)
Agent iast_HARDCODED_SECRET_DISABLED 1.17 s 96.225 ms (9.0%)
Agent iast_TELEMETRY_OFF 1.166 s 92.103 ms (8.6%)
Total tracing 8.516 s -
Total iast 8.921 s 404.893 ms (4.8%)
Total iast_HARDCODED_SECRET_DISABLED 8.909 s 392.959 ms (4.6%)
Total iast_TELEMETRY_OFF 8.937 s 421.402 ms (4.9%)
gantt
    title insecure-bank - break down per module: candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (665.082 ms) : 0, 665082
BytebuddyAgent [candidate] (673.983 ms) : 0, 673983
GlobalTracer [baseline] (304.137 ms) : 0, 304137
GlobalTracer [candidate] (306.426 ms) : 0, 306426
AppSec [baseline] (49.946 ms) : 0, 49946
AppSec [candidate] (50.379 ms) : 0, 50379
Remote Config [baseline] (684.743 µs) : 0, 685
Remote Config [candidate] (670.55 µs) : 0, 671
Telemetry [baseline] (7.721 ms) : 0, 7721
Telemetry [candidate] (7.615 ms) : 0, 7615
section iast
BytebuddyAgent [baseline] (779.041 ms) : 0, 779041
BytebuddyAgent [candidate] (779.821 ms) : 0, 779821
GlobalTracer [baseline] (294.931 ms) : 0, 294931
GlobalTracer [candidate] (295.27 ms) : 0, 295270
AppSec [baseline] (48.652 ms) : 0, 48652
AppSec [candidate] (47.858 ms) : 0, 47858
IAST [baseline] (26.13 ms) : 0, 26130
IAST [candidate] (27.337 ms) : 0, 27337
Remote Config [baseline] (573.68 µs) : 0, 574
Remote Config [candidate] (552.348 µs) : 0, 552
Telemetry [baseline] (6.942 ms) : 0, 6942
Telemetry [candidate] (6.87 ms) : 0, 6870
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (789.959 ms) : 0, 789959
BytebuddyAgent [candidate] (778.789 ms) : 0, 778789
GlobalTracer [baseline] (296.707 ms) : 0, 296707
GlobalTracer [candidate] (295.377 ms) : 0, 295377
AppSec [baseline] (48.454 ms) : 0, 48454
AppSec [candidate] (47.297 ms) : 0, 47297
IAST [baseline] (26.497 ms) : 0, 26497
IAST [candidate] (27.875 ms) : 0, 27875
Remote Config [baseline] (564.685 µs) : 0, 565
Remote Config [candidate] (561.121 µs) : 0, 561
Telemetry [baseline] (6.971 ms) : 0, 6971
Telemetry [candidate] (6.926 ms) : 0, 6926
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (782.339 ms) : 0, 782339
BytebuddyAgent [candidate] (776.261 ms) : 0, 776261
GlobalTracer [baseline] (296.738 ms) : 0, 296738
GlobalTracer [candidate] (294.877 ms) : 0, 294877
AppSec [baseline] (47.719 ms) : 0, 47719
AppSec [candidate] (47.319 ms) : 0, 47319
IAST [baseline] (27.959 ms) : 0, 27959
IAST [candidate] (25.985 ms) : 0, 25985
Remote Config [baseline] (573.76 µs) : 0, 574
Remote Config [candidate] (614.125 µs) : 0, 614
Telemetry [baseline] (6.87 ms) : 0, 6870
Telemetry [candidate] (7.62 ms) : 0, 7620
Loading
Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.066 s) : 0, 1066074
Total [baseline] (10.359 s) : 0, 10359110
Agent [candidate] (1.061 s) : 0, 1060825
Total [candidate] (10.356 s) : 0, 10355620
section appsec
Agent [baseline] (1.19 s) : 0, 1190489
Total [baseline] (10.504 s) : 0, 10504031
Agent [candidate] (1.187 s) : 0, 1186948
Total [candidate] (10.54 s) : 0, 10540057
section iast
Agent [baseline] (1.171 s) : 0, 1170745
Total [baseline] (10.693 s) : 0, 10692732
Agent [candidate] (1.173 s) : 0, 1173375
Total [candidate] (10.745 s) : 0, 10744775
section profiling
Agent [baseline] (1.272 s) : 0, 1271886
Total [baseline] (10.618 s) : 0, 10617891
Agent [candidate] (1.265 s) : 0, 1264773
Total [candidate] (10.59 s) : 0, 10590048
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.066 s -
Agent appsec 1.19 s 124.415 ms (11.7%)
Agent iast 1.171 s 104.671 ms (9.8%)
Agent profiling 1.272 s 205.812 ms (19.3%)
Total tracing 10.359 s -
Total appsec 10.504 s 144.92 ms (1.4%)
Total iast 10.693 s 333.622 ms (3.2%)
Total profiling 10.618 s 258.781 ms (2.5%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.061 s -
Agent appsec 1.187 s 126.123 ms (11.9%)
Agent iast 1.173 s 112.55 ms (10.6%)
Agent profiling 1.265 s 203.948 ms (19.2%)
Total tracing 10.356 s -
Total appsec 10.54 s 184.438 ms (1.8%)
Total iast 10.745 s 389.155 ms (3.8%)
Total profiling 10.59 s 234.429 ms (2.3%)
gantt
    title petclinic - break down per module: candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (666.714 ms) : 0, 666714
BytebuddyAgent [candidate] (664.014 ms) : 0, 664014
GlobalTracer [baseline] (306.19 ms) : 0, 306190
GlobalTracer [candidate] (304.063 ms) : 0, 304063
AppSec [baseline] (50.196 ms) : 0, 50196
AppSec [candidate] (49.901 ms) : 0, 49901
Remote Config [baseline] (675.055 µs) : 0, 675
Remote Config [candidate] (662.047 µs) : 0, 662
Telemetry [baseline] (7.677 ms) : 0, 7677
Telemetry [candidate] (7.594 ms) : 0, 7594
section appsec
BytebuddyAgent [baseline] (680.365 ms) : 0, 680365
BytebuddyAgent [candidate] (677.998 ms) : 0, 677998
GlobalTracer [baseline] (300.434 ms) : 0, 300434
GlobalTracer [candidate] (299.94 ms) : 0, 299940
AppSec [baseline] (154.19 ms) : 0, 154190
AppSec [candidate] (154.146 ms) : 0, 154146
Remote Config [baseline] (615.402 µs) : 0, 615
Remote Config [candidate] (625.148 µs) : 0, 625
Telemetry [baseline] (8.944 ms) : 0, 8944
Telemetry [candidate] (9.261 ms) : 0, 9261
IAST [baseline] (22.165 ms) : 0, 22165
IAST [candidate] (20.361 ms) : 0, 20361
section iast
BytebuddyAgent [baseline] (780.174 ms) : 0, 780174
BytebuddyAgent [candidate] (780.041 ms) : 0, 780041
GlobalTracer [baseline] (294.865 ms) : 0, 294865
GlobalTracer [candidate] (295.906 ms) : 0, 295906
AppSec [baseline] (48.036 ms) : 0, 48036
AppSec [candidate] (47.33 ms) : 0, 47330
Remote Config [baseline] (591.218 µs) : 0, 591
Remote Config [candidate] (568.269 µs) : 0, 568
Telemetry [baseline] (7.031 ms) : 0, 7031
Telemetry [candidate] (6.995 ms) : 0, 6995
IAST [baseline] (26.492 ms) : 0, 26492
IAST [candidate] (28.955 ms) : 0, 28955
section profiling
BytebuddyAgent [baseline] (666.703 ms) : 0, 666703
BytebuddyAgent [candidate] (662.912 ms) : 0, 662912
GlobalTracer [baseline] (390.109 ms) : 0, 390109
GlobalTracer [candidate] (389.06 ms) : 0, 389060
AppSec [baseline] (52.153 ms) : 0, 52153
AppSec [candidate] (51.774 ms) : 0, 51774
Remote Config [baseline] (661.215 µs) : 0, 661
Remote Config [candidate] (647.354 µs) : 0, 647
Telemetry [baseline] (7.386 ms) : 0, 7386
Telemetry [candidate] (7.416 ms) : 0, 7416
ProfilingAgent [baseline] (97.226 ms) : 0, 97226
ProfilingAgent [candidate] (95.675 ms) : 0, 95675
Profiling [baseline] (97.251 ms) : 0, 97251
Profiling [candidate] (95.699 ms) : 0, 95699
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2024-07-15T13:35:01 2024-07-15T13:41:50
git_branch master bbujon/refactor-scope-listener
git_commit_date 1721038044 1721049769
git_commit_sha f88def8 086ab60
release_version 1.38.0-SNAPSHOT~f88def8618 1.38.0-SNAPSHOT~086ab609b9
start_time 2024-07-15T13:34:47 2024-07-15T13:41:37
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1721051255 1721051255
ci_job_id 572307938 572307938
ci_pipeline_id 39150443 39150443
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
variant iast iast

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 16 unstable metrics.

Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.349 ms) : 1330, 1368
.   : milestone, 1349,
appsec (1.703 ms) : 1680, 1727
.   : milestone, 1703,
appsec_no_iast (1.727 ms) : 1704, 1751
.   : milestone, 1727,
iast (1.491 ms) : 1469, 1514
.   : milestone, 1491,
profiling (1.484 ms) : 1459, 1509
.   : milestone, 1484,
tracing (1.477 ms) : 1454, 1501
.   : milestone, 1477,
section candidate
no_agent (1.344 ms) : 1325, 1364
.   : milestone, 1344,
appsec (1.716 ms) : 1693, 1740
.   : milestone, 1716,
appsec_no_iast (1.714 ms) : 1689, 1739
.   : milestone, 1714,
iast (1.49 ms) : 1468, 1513
.   : milestone, 1490,
profiling (1.492 ms) : 1467, 1517
.   : milestone, 1492,
tracing (1.47 ms) : 1447, 1494
.   : milestone, 1470,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.349 ms [1.33 ms, 1.368 ms] -
appsec 1.703 ms [1.68 ms, 1.727 ms] 354.867 µs (26.3%)
appsec_no_iast 1.727 ms [1.704 ms, 1.751 ms] 378.778 µs (28.1%)
iast 1.491 ms [1.469 ms, 1.514 ms] 142.625 µs (10.6%)
profiling 1.484 ms [1.459 ms, 1.509 ms] 135.514 µs (10.0%)
tracing 1.477 ms [1.454 ms, 1.501 ms] 128.785 µs (9.5%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.344 ms [1.325 ms, 1.364 ms] -
appsec 1.716 ms [1.693 ms, 1.74 ms] 372.138 µs (27.7%)
appsec_no_iast 1.714 ms [1.689 ms, 1.739 ms] 369.341 µs (27.5%)
iast 1.49 ms [1.468 ms, 1.513 ms] 145.834 µs (10.8%)
profiling 1.492 ms [1.467 ms, 1.517 ms] 147.655 µs (11.0%)
tracing 1.47 ms [1.447 ms, 1.494 ms] 126.2 µs (9.4%)
Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618
    dateFormat X
    axisFormat %s
section baseline
no_agent (366.756 µs) : 346, 387
.   : milestone, 367,
iast (484.553 µs) : 463, 506
.   : milestone, 485,
iast_FULL (556.091 µs) : 535, 577
.   : milestone, 556,
iast_GLOBAL (511.665 µs) : 489, 534
.   : milestone, 512,
iast_HARDCODED_SECRET_DISABLED (478.713 µs) : 458, 499
.   : milestone, 479,
iast_INACTIVE (465.652 µs) : 444, 487
.   : milestone, 466,
iast_TELEMETRY_OFF (464.044 µs) : 443, 485
.   : milestone, 464,
tracing (439.227 µs) : 419, 459
.   : milestone, 439,
section candidate
no_agent (366.232 µs) : 345, 387
.   : milestone, 366,
iast (487.299 µs) : 466, 509
.   : milestone, 487,
iast_FULL (560.994 µs) : 540, 582
.   : milestone, 561,
iast_GLOBAL (515.573 µs) : 493, 538
.   : milestone, 516,
iast_HARDCODED_SECRET_DISABLED (486.291 µs) : 465, 507
.   : milestone, 486,
iast_INACTIVE (449.96 µs) : 429, 471
.   : milestone, 450,
iast_TELEMETRY_OFF (472.71 µs) : 451, 494
.   : milestone, 473,
tracing (446.117 µs) : 425, 468
.   : milestone, 446,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 366.756 µs [346.047 µs, 387.465 µs] -
iast 484.553 µs [463.212 µs, 505.895 µs] 117.797 µs (32.1%)
iast_FULL 556.091 µs [534.986 µs, 577.196 µs] 189.335 µs (51.6%)
iast_GLOBAL 511.665 µs [489.352 µs, 533.979 µs] 144.909 µs (39.5%)
iast_HARDCODED_SECRET_DISABLED 478.713 µs [457.972 µs, 499.453 µs] 111.956 µs (30.5%)
iast_INACTIVE 465.652 µs [444.369 µs, 486.934 µs] 98.896 µs (27.0%)
iast_TELEMETRY_OFF 464.044 µs [443.311 µs, 484.776 µs] 97.287 µs (26.5%)
tracing 439.227 µs [418.998 µs, 459.455 µs] 72.471 µs (19.8%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 366.232 µs [345.223 µs, 387.241 µs] -
iast 487.299 µs [466.019 µs, 508.579 µs] 121.067 µs (33.1%)
iast_FULL 560.994 µs [539.869 µs, 582.119 µs] 194.762 µs (53.2%)
iast_GLOBAL 515.573 µs [493.192 µs, 537.954 µs] 149.341 µs (40.8%)
iast_HARDCODED_SECRET_DISABLED 486.291 µs [465.266 µs, 507.316 µs] 120.059 µs (32.8%)
iast_INACTIVE 449.96 µs [429.206 µs, 470.714 µs] 83.728 µs (22.9%)
iast_TELEMETRY_OFF 472.71 µs [451.352 µs, 494.069 µs] 106.479 µs (29.1%)
tracing 446.117 µs [424.608 µs, 467.625 µs] 79.885 µs (21.8%)

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/refactor-scope-listener
git_commit_date 1721038044 1721049769
git_commit_sha f88def8 086ab60
release_version 1.38.0-SNAPSHOT~f88def8618 1.38.0-SNAPSHOT~086ab609b9
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1721051763 1721051763
ci_job_id 572307939 572307939
ci_pipeline_id 39150443 39150443
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
variant appsec appsec

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics.

Execution time for biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618
    dateFormat X
    axisFormat %s
section baseline
no_agent (15.466 s) : 15466000, 15466000
.   : milestone, 15466000,
appsec (15.221 s) : 15221000, 15221000
.   : milestone, 15221000,
iast (18.806 s) : 18806000, 18806000
.   : milestone, 18806000,
iast_GLOBAL (18.029 s) : 18029000, 18029000
.   : milestone, 18029000,
profiling (15.271 s) : 15271000, 15271000
.   : milestone, 15271000,
tracing (15.114 s) : 15114000, 15114000
.   : milestone, 15114000,
section candidate
no_agent (14.96 s) : 14960000, 14960000
.   : milestone, 14960000,
appsec (14.904 s) : 14904000, 14904000
.   : milestone, 14904000,
iast (18.61 s) : 18610000, 18610000
.   : milestone, 18610000,
iast_GLOBAL (18.052 s) : 18052000, 18052000
.   : milestone, 18052000,
profiling (15.188 s) : 15188000, 15188000
.   : milestone, 15188000,
tracing (15.039 s) : 15039000, 15039000
.   : milestone, 15039000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 15.466 s [15.466 s, 15.466 s] -
appsec 15.221 s [15.221 s, 15.221 s] -245.0 ms (-1.6%)
iast 18.806 s [18.806 s, 18.806 s] 3.34 s (21.6%)
iast_GLOBAL 18.029 s [18.029 s, 18.029 s] 2.563 s (16.6%)
profiling 15.271 s [15.271 s, 15.271 s] -195.0 ms (-1.3%)
tracing 15.114 s [15.114 s, 15.114 s] -352.0 ms (-2.3%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.96 s [14.96 s, 14.96 s] -
appsec 14.904 s [14.904 s, 14.904 s] -56.0 ms (-0.4%)
iast 18.61 s [18.61 s, 18.61 s] 3.65 s (24.4%)
iast_GLOBAL 18.052 s [18.052 s, 18.052 s] 3.092 s (20.7%)
profiling 15.188 s [15.188 s, 15.188 s] 228.0 ms (1.5%)
tracing 15.039 s [15.039 s, 15.039 s] 79.0 ms (0.5%)
Execution time for tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.38.0-SNAPSHOT~086ab609b9, baseline=1.38.0-SNAPSHOT~f88def8618
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.457 ms) : 1445, 1468
.   : milestone, 1457,
appsec (2.193 ms) : 2158, 2228
.   : milestone, 2193,
iast (1.955 ms) : 1913, 1997
.   : milestone, 1955,
iast_GLOBAL (1.996 ms) : 1954, 2038
.   : milestone, 1996,
profiling (1.838 ms) : 1804, 1871
.   : milestone, 1838,
tracing (1.829 ms) : 1796, 1862
.   : milestone, 1829,
section candidate
no_agent (1.453 ms) : 1442, 1465
.   : milestone, 1453,
appsec (2.199 ms) : 2164, 2233
.   : milestone, 2199,
iast (1.959 ms) : 1917, 2000
.   : milestone, 1959,
iast_GLOBAL (1.998 ms) : 1957, 2040
.   : milestone, 1998,
profiling (1.853 ms) : 1817, 1889
.   : milestone, 1853,
tracing (1.82 ms) : 1788, 1853
.   : milestone, 1820,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.457 ms [1.445 ms, 1.468 ms] -
appsec 2.193 ms [2.158 ms, 2.228 ms] 736.149 µs (50.5%)
iast 1.955 ms [1.913 ms, 1.997 ms] 498.248 µs (34.2%)
iast_GLOBAL 1.996 ms [1.954 ms, 2.038 ms] 539.192 µs (37.0%)
profiling 1.838 ms [1.804 ms, 1.871 ms] 380.872 µs (26.1%)
tracing 1.829 ms [1.796 ms, 1.862 ms] 371.832 µs (25.5%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.453 ms [1.442 ms, 1.465 ms] -
appsec 2.199 ms [2.164 ms, 2.233 ms] 745.645 µs (51.3%)
iast 1.959 ms [1.917 ms, 2.0 ms] 505.486 µs (34.8%)
iast_GLOBAL 1.998 ms [1.957 ms, 2.04 ms] 545.088 µs (37.5%)
profiling 1.853 ms [1.817 ms, 1.889 ms] 399.799 µs (27.5%)
tracing 1.82 ms [1.788 ms, 1.853 ms] 367.217 µs (25.3%)

@PerfectSlayer PerfectSlayer force-pushed the bbujon/refactor-scope-listener branch 2 times, most recently from 26a1c8e to 341f749 Compare July 9, 2024 11:57
@PerfectSlayer PerfectSlayer marked this pull request as ready for review July 9, 2024 13:26
@PerfectSlayer PerfectSlayer requested a review from a team as a code owner July 9, 2024 13:26
add(CorrelationIdentifier.getSpanIdKey(), DDSpanId.toString(spanId));
}
public void afterScopeActivated() {
add(CorrelationIdentifier.getTraceIdKey(), CorrelationIdentifier.getTraceId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes support for dynamically turning log injection on/off - was that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. My question is how is it supposed to work?
Because it looks only log4j2 uses it where all other logging frameworks don't support the feature 🤔
Should not the agent helper class be a listener of the remote config instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git log is your friend ;)

LogContextScopeListener was already used by the log4j2 instrumentation to inject the active span into the log4j2 MDC. PR #5221 updated this existing listener so it only injected the active span when log injection was dynamically enabled.

Other logging instrumentations take a different approach and instrument the appropriate record/event classes to inject the active span when the MDC is being updated. They do the same isLogsInjectionEnabled check, but at a different point.

So if you want to simplify the listener without breaking support for dynamically turning log injection on/off in log4j2 then you have 2 options:

  1. find a different instrumentation point for log4j2 which avoids the need to use a scope listener
  2. add a check for AgentTracer.traceConfig().isLogsInjectionEnabled() in the log scope listener

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note for consistency reasons the dynamic config for a trace is locked in when that trace starts. This is to avoid issues where the sampling config changes mid-trace, because otherwise you would be applying different rules to different parts of the same trace.

This is done by using a copy-on-write approach for dynamic config when the remote config changes, with each trace taking a reference to the current dynamic config snapshot when it starts. This avoids having to take a copy on every trace, because traces occur frequently whereas remote config changes happen infrequently.

AgentTracer.traceConfig() accesses the current snapshot, which involves at most a couple of volatile reads (one to get the tracer, another to get its latest dynamic config) plus a few field accesses to get the log injection state. This isn't much more than you'd need if the log scope listener had its own remote-config listener.

Copy link
Contributor Author

@PerfectSlayer PerfectSlayer Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed feedback.

For now, I will simply use the AgentTracer.traceConfig().isLogsInjectionEnabled() check.

I had a look at how to change the instrumentation for Log4j2 prior to 2.7 (when ContextDataInjector was introduced). It should be doable to it instrumenting ThreadContext or ThreadContextMap.
But I also saw that ContextDataInjector is deprecated since 2.13 in favor of ContextDataProvider:

NOTE: It is no longer recommended that custom implementations of this interface be provided as it is difficult to do. Instead, provide a custom ContextDataProvider.

From ContextDataInjector Javadoc and:

The ContextDataProvider (introduced in Log4j 2.13.2) is an interface applications and libraries can use to inject additional key-value pairs into the LogEvent's context data.

From Log4j extension documentation. So I wonder if it would better if I pair with @amarziali and get to the bottom of it rather than just patching <2.7 only.

@PerfectSlayer PerfectSlayer merged commit 459a6aa into master Jul 17, 2024
82 checks passed
@PerfectSlayer PerfectSlayer deleted the bbujon/refactor-scope-listener branch July 17, 2024 10:34
@github-actions github-actions bot added this to the 1.37.1 milestone Jul 17, 2024
@PerfectSlayer PerfectSlayer modified the milestones: 1.37.1, 1.38.0 Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: core Tracer core tag: no release notes Changes to exclude from release notes type: refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants