Skip to content

Conversation

@PerfectSlayer
Copy link
Contributor

@PerfectSlayer PerfectSlayer commented Aug 19, 2025

What Does This Do

This PR continues @zarirhamza work about Serverless gateway inferred span in #8336 and brings the following improvements:

  • 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

Motivation

Restore Serverless feature while meeting design and performance requirements

Additional Notes

This requires to complete the instrumentation refactoring first.
I already did a lot of them here:

The last one is pending for review:

Contributor Checklist

Jira ticket: LANGPLAT-680

@PerfectSlayer PerfectSlayer added tag: do not merge Do not merge changes inst: others All other instrumentations type: refactoring tag: serverless Serverless support labels Aug 19, 2025
@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Aug 19, 2025

🎯 Code Coverage
Patch Coverage: 77.33%
Total Coverage: 59.83% (-0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6f9eee1 | Docs | Was this helpful? Give us feedback!

@pr-commenter
Copy link

pr-commenter bot commented Aug 19, 2025

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/gateway-inferred-span2
git_commit_date 1758546007 1758546261
git_commit_sha 4313a72 6f9eee1
release_version 1.54.0-SNAPSHOT~4313a72404 1.54.0-SNAPSHOT~6f9eee1e64
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1758548213 1758548213
ci_job_id 1140798000 1140798000
ci_pipeline_id 77154578 77154578
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-jgvkm8wf 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-jgvkm8wf 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
module Agent Agent
parent None None

Summary

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

Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.02 s) : 0, 1019610
Total [baseline] (10.7 s) : 0, 10699545
Agent [candidate] (1.022 s) : 0, 1022423
Total [candidate] (10.681 s) : 0, 10680600
section appsec
Agent [baseline] (1.199 s) : 0, 1198955
Total [baseline] (11.063 s) : 0, 11062913
Agent [candidate] (1.196 s) : 0, 1195933
Total [candidate] (11.104 s) : 0, 11104162
section iast
Agent [baseline] (1.153 s) : 0, 1153212
Total [baseline] (11.048 s) : 0, 11048242
Agent [candidate] (1.154 s) : 0, 1154086
Total [candidate] (11.05 s) : 0, 11049691
section profiling
Agent [baseline] (1.163 s) : 0, 1162625
Total [baseline] (11.041 s) : 0, 11041465
Agent [candidate] (1.166 s) : 0, 1166365
Total [candidate] (11.064 s) : 0, 11063596
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.02 s -
Agent appsec 1.199 s 179.345 ms (17.6%)
Agent iast 1.153 s 133.601 ms (13.1%)
Agent profiling 1.163 s 143.015 ms (14.0%)
Total tracing 10.7 s -
Total appsec 11.063 s 363.368 ms (3.4%)
Total iast 11.048 s 348.697 ms (3.3%)
Total profiling 11.041 s 341.92 ms (3.2%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.022 s -
Agent appsec 1.196 s 173.51 ms (17.0%)
Agent iast 1.154 s 131.663 ms (12.9%)
Agent profiling 1.166 s 143.942 ms (14.1%)
Total tracing 10.681 s -
Total appsec 11.104 s 423.561 ms (4.0%)
Total iast 11.05 s 369.091 ms (3.5%)
Total profiling 11.064 s 382.995 ms (3.6%)
gantt
    title petclinic - break down per module: candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404

    dateFormat X
    axisFormat %s
section tracing
crashtracking [baseline] (1.447 ms) : 0, 1447
crashtracking [candidate] (1.455 ms) : 0, 1455
BytebuddyAgent [baseline] (687.139 ms) : 0, 687139
BytebuddyAgent [candidate] (691.167 ms) : 0, 691167
GlobalTracer [baseline] (258.096 ms) : 0, 258096
GlobalTracer [candidate] (259.527 ms) : 0, 259527
AppSec [baseline] (31.687 ms) : 0, 31687
AppSec [candidate] (31.873 ms) : 0, 31873
Debugger [baseline] (6.352 ms) : 0, 6352
Debugger [candidate] (6.39 ms) : 0, 6390
Remote Config [baseline] (669.399 µs) : 0, 669
Remote Config [candidate] (678.945 µs) : 0, 679
Telemetry [baseline] (13.253 ms) : 0, 13253
Telemetry [candidate] (10.267 ms) : 0, 10267
section appsec
crashtracking [baseline] (1.462 ms) : 0, 1462
crashtracking [candidate] (1.459 ms) : 0, 1459
BytebuddyAgent [baseline] (712.154 ms) : 0, 712154
BytebuddyAgent [candidate] (710.303 ms) : 0, 710303
GlobalTracer [baseline] (251.437 ms) : 0, 251437
GlobalTracer [candidate] (250.723 ms) : 0, 250723
IAST [baseline] (25.072 ms) : 0, 25072
IAST [candidate] (25.009 ms) : 0, 25009
AppSec [baseline] (170.433 ms) : 0, 170433
AppSec [candidate] (170.755 ms) : 0, 170755
Debugger [baseline] (6.128 ms) : 0, 6128
Debugger [candidate] (6.145 ms) : 0, 6145
Remote Config [baseline] (614.362 µs) : 0, 614
Remote Config [candidate] (609.531 µs) : 0, 610
Telemetry [baseline] (10.587 ms) : 0, 10587
Telemetry [candidate] (9.877 ms) : 0, 9877
section iast
crashtracking [baseline] (1.455 ms) : 0, 1455
crashtracking [candidate] (1.449 ms) : 0, 1449
BytebuddyAgent [baseline] (807.753 ms) : 0, 807753
BytebuddyAgent [candidate] (808.726 ms) : 0, 808726
GlobalTracer [baseline] (249.214 ms) : 0, 249214
GlobalTracer [candidate] (249.265 ms) : 0, 249265
IAST [baseline] (30.038 ms) : 0, 30038
IAST [candidate] (29.266 ms) : 0, 29266
AppSec [baseline] (28.919 ms) : 0, 28919
AppSec [candidate] (29.566 ms) : 0, 29566
Debugger [baseline] (6.081 ms) : 0, 6081
Debugger [candidate] (6.047 ms) : 0, 6047
Remote Config [baseline] (586.687 µs) : 0, 587
Remote Config [candidate] (583.036 µs) : 0, 583
Telemetry [baseline] (8.132 ms) : 0, 8132
Telemetry [candidate] (8.127 ms) : 0, 8127
section profiling
crashtracking [baseline] (1.422 ms) : 0, 1422
crashtracking [candidate] (1.429 ms) : 0, 1429
BytebuddyAgent [baseline] (717.688 ms) : 0, 717688
BytebuddyAgent [candidate] (720.193 ms) : 0, 720193
GlobalTracer [baseline] (236.584 ms) : 0, 236584
GlobalTracer [candidate] (237.107 ms) : 0, 237107
AppSec [baseline] (31.082 ms) : 0, 31082
AppSec [candidate] (31.427 ms) : 0, 31427
Debugger [baseline] (6.477 ms) : 0, 6477
Debugger [candidate] (6.487 ms) : 0, 6487
Remote Config [baseline] (689.313 µs) : 0, 689
Remote Config [candidate] (709.256 µs) : 0, 709
Telemetry [baseline] (16.411 ms) : 0, 16411
Telemetry [candidate] (16.37 ms) : 0, 16370
ProfilingAgent [baseline] (101.357 ms) : 0, 101357
ProfilingAgent [candidate] (101.668 ms) : 0, 101668
Profiling [baseline] (101.956 ms) : 0, 101956
Profiling [candidate] (102.264 ms) : 0, 102264
Loading
Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.027 s) : 0, 1027018
Total [baseline] (8.682 s) : 0, 8681621
Agent [candidate] (1.023 s) : 0, 1023041
Total [candidate] (8.668 s) : 0, 8668282
section iast
Agent [baseline] (1.163 s) : 0, 1162915
Total [baseline] (9.393 s) : 0, 9393463
Agent [candidate] (1.16 s) : 0, 1159754
Total [candidate] (9.417 s) : 0, 9417397
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.027 s -
Agent iast 1.163 s 135.897 ms (13.2%)
Total tracing 8.682 s -
Total iast 9.393 s 711.842 ms (8.2%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.023 s -
Agent iast 1.16 s 136.713 ms (13.4%)
Total tracing 8.668 s -
Total iast 9.417 s 749.115 ms (8.6%)
gantt
    title insecure-bank - break down per module: candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404

    dateFormat X
    axisFormat %s
section tracing
crashtracking [baseline] (1.471 ms) : 0, 1471
crashtracking [candidate] (1.437 ms) : 0, 1437
BytebuddyAgent [baseline] (691.846 ms) : 0, 691846
BytebuddyAgent [candidate] (687.169 ms) : 0, 687169
GlobalTracer [baseline] (259.551 ms) : 0, 259551
GlobalTracer [candidate] (259.79 ms) : 0, 259790
AppSec [baseline] (31.787 ms) : 0, 31787
AppSec [candidate] (31.776 ms) : 0, 31776
Debugger [baseline] (6.388 ms) : 0, 6388
Debugger [candidate] (6.37 ms) : 0, 6370
Remote Config [baseline] (686.33 µs) : 0, 686
Remote Config [candidate] (674.357 µs) : 0, 674
Telemetry [baseline] (14.164 ms) : 0, 14164
Telemetry [candidate] (14.859 ms) : 0, 14859
section iast
crashtracking [baseline] (1.458 ms) : 0, 1458
crashtracking [candidate] (1.464 ms) : 0, 1464
BytebuddyAgent [baseline] (815.925 ms) : 0, 815925
BytebuddyAgent [candidate] (811.415 ms) : 0, 811415
GlobalTracer [baseline] (250.735 ms) : 0, 250735
GlobalTracer [candidate] (251.593 ms) : 0, 251593
IAST [baseline] (29.094 ms) : 0, 29094
IAST [candidate] (31.597 ms) : 0, 31597
AppSec [baseline] (29.675 ms) : 0, 29675
AppSec [candidate] (27.653 ms) : 0, 27653
Debugger [baseline] (6.091 ms) : 0, 6091
Debugger [candidate] (6.211 ms) : 0, 6211
Remote Config [baseline] (598.263 µs) : 0, 598
Remote Config [candidate] (603.218 µs) : 0, 603
Telemetry [baseline] (8.242 ms) : 0, 8242
Telemetry [candidate] (8.248 ms) : 0, 8248
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/gateway-inferred-span2
git_commit_date 1758546007 1758546261
git_commit_sha 4313a72 6f9eee1
release_version 1.54.0-SNAPSHOT~4313a72404 1.54.0-SNAPSHOT~6f9eee1e64
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1758547951 1758547951
ci_job_id 1140798001 1140798001
ci_pipeline_id 77154578 77154578
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-1-deogr91y 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-1-deogr91y 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Summary

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

scenario Δ mean http_req_duration Δ mean throughput candidate mean http_req_duration candidate mean throughput baseline mean http_req_duration baseline mean throughput
scenario:load:insecure-bank:profiling:high_load better
[-540.167µs; -238.548µs] or [-6.009%; -2.654%]
unstable
[-43.707op/s; +90.207op/s] or [-8.470%; +17.482%]
8.601ms 539.250op/s 8.990ms 516.000op/s
scenario:load:insecure-bank:tracing:high_load better
[-661.512µs; -408.091µs] or [-7.923%; -4.888%]
unstable
[-33.223op/s; +108.035op/s] or [-5.982%; +19.453%]
7.815ms 592.781op/s 8.350ms 555.375op/s
scenario:load:insecure-bank:iast_FULL:high_load better
[-1.453ms; -0.824ms] or [-9.473%; -5.373%]
unstable
[-10.884op/s; +59.259op/s] or [-3.582%; +19.503%]
14.203ms 328.031op/s 15.342ms 303.844op/s
scenario:load:insecure-bank:iast:high_load worse
[+752.898µs; +1123.724µs] or [+7.809%; +11.655%]
unstable
[-96.801op/s; +13.551op/s] or [-20.104%; +2.814%]
10.580ms 439.875op/s 9.642ms 481.500op/s
Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404
    dateFormat X
    axisFormat %s
section baseline
no_agent (4.312 ms) : 4263, 4362
.   : milestone, 4312,
iast (9.642 ms) : 9478, 9805
.   : milestone, 9642,
iast_FULL (15.342 ms) : 15039, 15644
.   : milestone, 15342,
iast_GLOBAL (10.283 ms) : 10102, 10464
.   : milestone, 10283,
profiling (8.99 ms) : 8842, 9138
.   : milestone, 8990,
tracing (8.35 ms) : 8228, 8471
.   : milestone, 8350,
section candidate
no_agent (4.211 ms) : 4160, 4262
.   : milestone, 4211,
iast (10.58 ms) : 10399, 10761
.   : milestone, 10580,
iast_FULL (14.203 ms) : 13921, 14484
.   : milestone, 14203,
iast_GLOBAL (10.592 ms) : 10403, 10781
.   : milestone, 10592,
profiling (8.601 ms) : 8469, 8732
.   : milestone, 8601,
tracing (7.815 ms) : 7701, 7929
.   : milestone, 7815,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 4.312 ms [4.263 ms, 4.362 ms] -
iast 9.642 ms [9.478 ms, 9.805 ms] 5.33 ms (123.6%)
iast_FULL 15.342 ms [15.039 ms, 15.644 ms] 11.029 ms (255.8%)
iast_GLOBAL 10.283 ms [10.102 ms, 10.464 ms] 5.971 ms (138.5%)
profiling 8.99 ms [8.842 ms, 9.138 ms] 4.678 ms (108.5%)
tracing 8.35 ms [8.228 ms, 8.471 ms] 4.037 ms (93.6%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 4.211 ms [4.16 ms, 4.262 ms] -
iast 10.58 ms [10.399 ms, 10.761 ms] 6.369 ms (151.3%)
iast_FULL 14.203 ms [13.921 ms, 14.484 ms] 9.992 ms (237.3%)
iast_GLOBAL 10.592 ms [10.403 ms, 10.781 ms] 6.381 ms (151.5%)
profiling 8.601 ms [8.469 ms, 8.732 ms] 4.39 ms (104.2%)
tracing 7.815 ms [7.701 ms, 7.929 ms] 3.604 ms (85.6%)
Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404
    dateFormat X
    axisFormat %s
section baseline
no_agent (36.651 ms) : 36361, 36941
.   : milestone, 36651,
appsec (47.056 ms) : 46658, 47454
.   : milestone, 47056,
code_origins (46.141 ms) : 45740, 46541
.   : milestone, 46141,
iast (43.975 ms) : 43588, 44362
.   : milestone, 43975,
profiling (47.225 ms) : 46807, 47643
.   : milestone, 47225,
tracing (44.596 ms) : 44219, 44973
.   : milestone, 44596,
section candidate
no_agent (36.768 ms) : 36474, 37062
.   : milestone, 36768,
appsec (47.245 ms) : 46828, 47662
.   : milestone, 47245,
code_origins (45.432 ms) : 45043, 45822
.   : milestone, 45432,
iast (45.004 ms) : 44623, 45386
.   : milestone, 45004,
profiling (47.866 ms) : 47408, 48323
.   : milestone, 47866,
tracing (43.805 ms) : 43416, 44193
.   : milestone, 43805,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 36.651 ms [36.361 ms, 36.941 ms] -
appsec 47.056 ms [46.658 ms, 47.454 ms] 10.405 ms (28.4%)
code_origins 46.141 ms [45.74 ms, 46.541 ms] 9.49 ms (25.9%)
iast 43.975 ms [43.588 ms, 44.362 ms] 7.324 ms (20.0%)
profiling 47.225 ms [46.807 ms, 47.643 ms] 10.574 ms (28.9%)
tracing 44.596 ms [44.219 ms, 44.973 ms] 7.945 ms (21.7%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 36.768 ms [36.474 ms, 37.062 ms] -
appsec 47.245 ms [46.828 ms, 47.662 ms] 10.477 ms (28.5%)
code_origins 45.432 ms [45.043 ms, 45.822 ms] 8.665 ms (23.6%)
iast 45.004 ms [44.623 ms, 45.386 ms] 8.237 ms (22.4%)
profiling 47.866 ms [47.408 ms, 48.323 ms] 11.098 ms (30.2%)
tracing 43.805 ms [43.416 ms, 44.193 ms] 7.037 ms (19.1%)

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/gateway-inferred-span2
git_commit_date 1758546007 1758546261
git_commit_sha 4313a72 6f9eee1
release_version 1.54.0-SNAPSHOT~4313a72404 1.54.0-SNAPSHOT~6f9eee1e64
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1758548474 1758548474
ci_job_id 1140798002 1140798002
ci_pipeline_id 77154578 77154578
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-zfyrx7zua-project-304-concurrent-0-cywlsjcr 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-zfyrx7zua-project-304-concurrent-0-cywlsjcr 6.8.0-1031-aws #33~22.04.1-Ubuntu SMP Thu Jun 26 14:22:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Summary

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

Execution time for tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.473 ms) : 1462, 1485
.   : milestone, 1473,
appsec (3.633 ms) : 3421, 3845
.   : milestone, 3633,
iast (2.203 ms) : 2140, 2265
.   : milestone, 2203,
iast_GLOBAL (2.244 ms) : 2181, 2307
.   : milestone, 2244,
profiling (2.076 ms) : 2024, 2128
.   : milestone, 2076,
tracing (2.024 ms) : 1975, 2073
.   : milestone, 2024,
section candidate
no_agent (1.474 ms) : 1463, 1486
.   : milestone, 1474,
appsec (3.706 ms) : 3488, 3923
.   : milestone, 3706,
iast (2.199 ms) : 2136, 2262
.   : milestone, 2199,
iast_GLOBAL (2.234 ms) : 2172, 2297
.   : milestone, 2234,
profiling (2.063 ms) : 2012, 2115
.   : milestone, 2063,
tracing (2.022 ms) : 1973, 2071
.   : milestone, 2022,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.473 ms [1.462 ms, 1.485 ms] -
appsec 3.633 ms [3.421 ms, 3.845 ms] 2.16 ms (146.6%)
iast 2.203 ms [2.14 ms, 2.265 ms] 729.32 µs (49.5%)
iast_GLOBAL 2.244 ms [2.181 ms, 2.307 ms] 770.708 µs (52.3%)
profiling 2.076 ms [2.024 ms, 2.128 ms] 602.668 µs (40.9%)
tracing 2.024 ms [1.975 ms, 2.073 ms] 550.774 µs (37.4%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.474 ms [1.463 ms, 1.486 ms] -
appsec 3.706 ms [3.488 ms, 3.923 ms] 2.231 ms (151.3%)
iast 2.199 ms [2.136 ms, 2.262 ms] 724.518 µs (49.1%)
iast_GLOBAL 2.234 ms [2.172 ms, 2.297 ms] 759.867 µs (51.5%)
profiling 2.063 ms [2.012 ms, 2.115 ms] 588.922 µs (39.9%)
tracing 2.022 ms [1.973 ms, 2.071 ms] 547.766 µs (37.1%)
Execution time for biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.54.0-SNAPSHOT~6f9eee1e64, baseline=1.54.0-SNAPSHOT~4313a72404
    dateFormat X
    axisFormat %s
section baseline
no_agent (15.011 s) : 15011000, 15011000
.   : milestone, 15011000,
appsec (14.975 s) : 14975000, 14975000
.   : milestone, 14975000,
iast (18.674 s) : 18674000, 18674000
.   : milestone, 18674000,
iast_GLOBAL (17.838 s) : 17838000, 17838000
.   : milestone, 17838000,
profiling (15.496 s) : 15496000, 15496000
.   : milestone, 15496000,
tracing (15.069 s) : 15069000, 15069000
.   : milestone, 15069000,
section candidate
no_agent (14.962 s) : 14962000, 14962000
.   : milestone, 14962000,
appsec (14.928 s) : 14928000, 14928000
.   : milestone, 14928000,
iast (18.765 s) : 18765000, 18765000
.   : milestone, 18765000,
iast_GLOBAL (18.033 s) : 18033000, 18033000
.   : milestone, 18033000,
profiling (15.394 s) : 15394000, 15394000
.   : milestone, 15394000,
tracing (14.876 s) : 14876000, 14876000
.   : milestone, 14876000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 15.011 s [15.011 s, 15.011 s] -
appsec 14.975 s [14.975 s, 14.975 s] -36.0 ms (-0.2%)
iast 18.674 s [18.674 s, 18.674 s] 3.663 s (24.4%)
iast_GLOBAL 17.838 s [17.838 s, 17.838 s] 2.827 s (18.8%)
profiling 15.496 s [15.496 s, 15.496 s] 485.0 ms (3.2%)
tracing 15.069 s [15.069 s, 15.069 s] 58.0 ms (0.4%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.962 s [14.962 s, 14.962 s] -
appsec 14.928 s [14.928 s, 14.928 s] -34.0 ms (-0.2%)
iast 18.765 s [18.765 s, 18.765 s] 3.803 s (25.4%)
iast_GLOBAL 18.033 s [18.033 s, 18.033 s] 3.071 s (20.5%)
profiling 15.394 s [15.394 s, 15.394 s] 432.0 ms (2.9%)
tracing 14.876 s [14.876 s, 14.876 s] -86.0 ms (-0.6%)

@PerfectSlayer PerfectSlayer marked this pull request as ready for review August 21, 2025 07:23
@PerfectSlayer PerfectSlayer requested review from a team as code owners August 21, 2025 07:23
@PerfectSlayer PerfectSlayer removed the tag: do not merge Do not merge changes label Aug 21, 2025
@PerfectSlayer PerfectSlayer force-pushed the bbujon/gateway-inferred-span2 branch 2 times, most recently from ad6356f to e8c2baf Compare August 21, 2025 07:53
@PerfectSlayer PerfectSlayer requested a review from a team as a code owner August 21, 2025 07:53
@PerfectSlayer PerfectSlayer requested review from AlexeyKuznetsov-DD and removed request for a team August 21, 2025 07:53
Comment on lines +65 to +68
long startTime;
try {
startTime = Long.parseLong(header(PROXY_START_TIME_MS)) * 1000; // Convert to microseconds
} catch (NumberFormatException e) {
return extracted; // Invalid timestamp
}
Copy link
Contributor

@AlexeyKuznetsov-DD AlexeyKuznetsov-DD Aug 26, 2025

Choose a reason for hiding this comment

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

I have a feeling that we need to have some sort of utility code for such places?
WDYT?
Something like: long startTime = parseLong((header(PROXY_START_TIME_MS), ?some_default? ) * 1000;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think you can have a default start time in this case.

Gateway inferred spans represent the duration spent in upstream proxy servers (that are not instrumented for distributed tracing, they only inject few Datadog headers).
The start time represents the timestamp the request was intercepted by the proxy server and will be use to create a "proxy span" into the downstream service.

So if you don't have a valid start time, it's most likely a proxy issue, and you can't really "guess" when the proxy intercepted the upstream request.

Copy link
Contributor

@amarziali amarziali left a comment

Choose a reason for hiding this comment

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

The change looks good. May we keep settings tags in a decorator to be sure we are consistent with other part of the code?

@PerfectSlayer PerfectSlayer force-pushed the bbujon/gateway-inferred-span2 branch 3 times, most recently from eb6874e to 735271a Compare September 22, 2025 11:51
* Creates inferred proxy spans for API Gateway calls via presence of http headers

---------

Co-authored-by: Zarir Hamza <[email protected]>
@PerfectSlayer
Copy link
Contributor Author

Rebasing to run load benchmark once again 🤷

Comment on lines 77 to 78
span.setTag(RESOURCE_NAME, header(PROXY_HTTP_METHOD) + " " + header(PROXY_PATH));
span.setTag(SERVICE_NAME, header(PROXY_DOMAIN_NAME));
Copy link
Contributor

Choose a reason for hiding this comment

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

service name and resource name can be set directly on the span. setting them through a tag will trigger the taginterceptor that will do the same but this is way less efficient

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched to the serviceName() method and removed the resource name in favor of the tag interceptor.

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
@PerfectSlayer PerfectSlayer force-pushed the bbujon/gateway-inferred-span2 branch from 735271a to 6f9eee1 Compare September 22, 2025 13:08
Copy link
Contributor

@amarziali amarziali left a comment

Choose a reason for hiding this comment

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

lgtm. Thanks for having addressed the comments and for the refactoring

@PerfectSlayer PerfectSlayer enabled auto-merge (squash) September 22, 2025 13:39
@PerfectSlayer PerfectSlayer merged commit ad25479 into master Sep 22, 2025
545 checks passed
@PerfectSlayer PerfectSlayer deleted the bbujon/gateway-inferred-span2 branch September 22, 2025 14:00
@github-actions github-actions bot added this to the 1.54.0 milestone Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst: others All other instrumentations tag: serverless Serverless support type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants