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.63%
Total Coverage: 57.56% (-0.01%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e8c2baf | 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 1755723343 1755762733
git_commit_sha 5aa25ba e8c2baf
release_version 1.53.0-SNAPSHOT~5aa25baa32 1.53.0-SNAPSHOT~e8c2bafaff
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1755764572 1755764572
ci_job_id 1091335704 1091335704
ci_pipeline_id 74337849 74337849
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-3ok4j59a 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-3ok4j59a 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 46 metrics, 13 unstable metrics.

Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.064 s) : 0, 1064413
Total [baseline] (10.821 s) : 0, 10821240
Agent [candidate] (1.046 s) : 0, 1045506
Total [candidate] (10.713 s) : 0, 10712996
section appsec
Agent [baseline] (1.222 s) : 0, 1222480
Total [baseline] (10.776 s) : 0, 10775761
Agent [candidate] (1.222 s) : 0, 1221646
Total [candidate] (10.781 s) : 0, 10781298
section iast
Agent [baseline] (1.179 s) : 0, 1178621
Total [baseline] (10.871 s) : 0, 10871406
Agent [candidate] (1.186 s) : 0, 1186454
Total [candidate] (10.939 s) : 0, 10938822
section profiling
Agent [baseline] (1.193 s) : 0, 1193475
Total [baseline] (10.813 s) : 0, 10813034
Agent [candidate] (1.196 s) : 0, 1196020
Total [candidate] (10.851 s) : 0, 10851198
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.064 s -
Agent appsec 1.222 s 158.067 ms (14.9%)
Agent iast 1.179 s 114.208 ms (10.7%)
Agent profiling 1.193 s 129.062 ms (12.1%)
Total tracing 10.821 s -
Total appsec 10.776 s -45.479 ms (-0.4%)
Total iast 10.871 s 50.166 ms (0.5%)
Total profiling 10.813 s -8.206 ms (-0.1%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.046 s -
Agent appsec 1.222 s 176.14 ms (16.8%)
Agent iast 1.186 s 140.948 ms (13.5%)
Agent profiling 1.196 s 150.513 ms (14.4%)
Total tracing 10.713 s -
Total appsec 10.781 s 68.302 ms (0.6%)
Total iast 10.939 s 225.825 ms (2.1%)
Total profiling 10.851 s 138.201 ms (1.3%)
gantt
    title petclinic - break down per module: candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32

    dateFormat X
    axisFormat %s
section tracing
crashtracking [baseline] (1.483 ms) : 0, 1483
crashtracking [candidate] (1.444 ms) : 0, 1444
BytebuddyAgent [baseline] (744.385 ms) : 0, 744385
BytebuddyAgent [candidate] (731.412 ms) : 0, 731412
GlobalTracer [baseline] (246.513 ms) : 0, 246513
GlobalTracer [candidate] (242.433 ms) : 0, 242433
AppSec [baseline] (30.726 ms) : 0, 30726
AppSec [candidate] (30.194 ms) : 0, 30194
Debugger [baseline] (6.144 ms) : 0, 6144
Debugger [candidate] (6.082 ms) : 0, 6082
Remote Config [baseline] (682.53 µs) : 0, 683
Remote Config [candidate] (668.655 µs) : 0, 669
Telemetry [baseline] (13.084 ms) : 0, 13084
Telemetry [candidate] (12.152 ms) : 0, 12152
section appsec
crashtracking [baseline] (1.443 ms) : 0, 1443
crashtracking [candidate] (1.464 ms) : 0, 1464
BytebuddyAgent [baseline] (754.934 ms) : 0, 754934
BytebuddyAgent [candidate] (754.423 ms) : 0, 754423
GlobalTracer [baseline] (235.29 ms) : 0, 235290
GlobalTracer [candidate] (234.915 ms) : 0, 234915
AppSec [baseline] (167.534 ms) : 0, 167534
AppSec [candidate] (168.318 ms) : 0, 168318
Debugger [baseline] (9.534 ms) : 0, 9534
Debugger [candidate] (8.027 ms) : 0, 8027
Remote Config [baseline] (631.414 µs) : 0, 631
Remote Config [candidate] (637.073 µs) : 0, 637
Telemetry [baseline] (8.44 ms) : 0, 8440
Telemetry [candidate] (9.272 ms) : 0, 9272
IAST [baseline] (23.561 ms) : 0, 23561
IAST [candidate] (23.494 ms) : 0, 23494
section iast
crashtracking [baseline] (1.449 ms) : 0, 1449
crashtracking [candidate] (1.465 ms) : 0, 1465
BytebuddyAgent [baseline] (850.523 ms) : 0, 850523
BytebuddyAgent [candidate] (857.224 ms) : 0, 857224
GlobalTracer [baseline] (232.901 ms) : 0, 232901
GlobalTracer [candidate] (234.938 ms) : 0, 234938
AppSec [baseline] (28.615 ms) : 0, 28615
AppSec [candidate] (26.686 ms) : 0, 26686
Debugger [baseline] (5.753 ms) : 0, 5753
Debugger [candidate] (6.593 ms) : 0, 6593
Remote Config [baseline] (601.341 µs) : 0, 601
Remote Config [candidate] (611.451 µs) : 0, 611
Telemetry [baseline] (8.377 ms) : 0, 8377
Telemetry [candidate] (8.223 ms) : 0, 8223
IAST [baseline] (29.367 ms) : 0, 29367
IAST [candidate] (29.582 ms) : 0, 29582
section profiling
crashtracking [baseline] (1.42 ms) : 0, 1420
crashtracking [candidate] (1.42 ms) : 0, 1420
BytebuddyAgent [baseline] (759.807 ms) : 0, 759807
BytebuddyAgent [candidate] (761.733 ms) : 0, 761733
GlobalTracer [baseline] (222.227 ms) : 0, 222227
GlobalTracer [candidate] (222.272 ms) : 0, 222272
AppSec [baseline] (29.874 ms) : 0, 29874
AppSec [candidate] (30.034 ms) : 0, 30034
Debugger [baseline] (6.29 ms) : 0, 6290
Debugger [candidate] (6.307 ms) : 0, 6307
Remote Config [baseline] (721.358 µs) : 0, 721
Remote Config [candidate] (714.603 µs) : 0, 715
Telemetry [baseline] (16.401 ms) : 0, 16401
Telemetry [candidate] (16.263 ms) : 0, 16263
ProfilingAgent [baseline] (107.234 ms) : 0, 107234
ProfilingAgent [candidate] (107.594 ms) : 0, 107594
Profiling [baseline] (107.856 ms) : 0, 107856
Profiling [candidate] (108.24 ms) : 0, 108240
Loading
Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.043 s) : 0, 1043136
Total [baseline] (8.605 s) : 0, 8604806
Agent [candidate] (1.051 s) : 0, 1050848
Total [candidate] (8.632 s) : 0, 8631864
section iast
Agent [baseline] (1.197 s) : 0, 1196515
Total [baseline] (9.33 s) : 0, 9329693
Agent [candidate] (1.181 s) : 0, 1181006
Total [candidate] (9.35 s) : 0, 9350307
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.043 s -
Agent iast 1.197 s 153.379 ms (14.7%)
Total tracing 8.605 s -
Total iast 9.33 s 724.887 ms (8.4%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.051 s -
Agent iast 1.181 s 130.158 ms (12.4%)
Total tracing 8.632 s -
Total iast 9.35 s 718.443 ms (8.3%)
gantt
    title insecure-bank - break down per module: candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32

    dateFormat X
    axisFormat %s
section tracing
crashtracking [baseline] (1.452 ms) : 0, 1452
crashtracking [candidate] (1.452 ms) : 0, 1452
BytebuddyAgent [baseline] (731.276 ms) : 0, 731276
BytebuddyAgent [candidate] (733.961 ms) : 0, 733961
GlobalTracer [baseline] (241.885 ms) : 0, 241885
GlobalTracer [candidate] (243.463 ms) : 0, 243463
AppSec [baseline] (29.965 ms) : 0, 29965
AppSec [candidate] (30.464 ms) : 0, 30464
Debugger [baseline] (6.071 ms) : 0, 6071
Debugger [candidate] (6.109 ms) : 0, 6109
Remote Config [baseline] (679.288 µs) : 0, 679
Remote Config [candidate] (680.337 µs) : 0, 680
Telemetry [baseline] (10.813 ms) : 0, 10813
Telemetry [candidate] (13.683 ms) : 0, 13683
section iast
crashtracking [baseline] (1.481 ms) : 0, 1481
crashtracking [candidate] (1.452 ms) : 0, 1452
BytebuddyAgent [baseline] (865.025 ms) : 0, 865025
BytebuddyAgent [candidate] (851.72 ms) : 0, 851720
GlobalTracer [baseline] (234.969 ms) : 0, 234969
GlobalTracer [candidate] (233.523 ms) : 0, 233523
AppSec [baseline] (27.281 ms) : 0, 27281
AppSec [candidate] (25.45 ms) : 0, 25450
Debugger [baseline] (6.588 ms) : 0, 6588
Debugger [candidate] (5.83 ms) : 0, 5830
Remote Config [baseline] (606.878 µs) : 0, 607
Remote Config [candidate] (599.855 µs) : 0, 600
Telemetry [baseline] (9.225 ms) : 0, 9225
Telemetry [candidate] (8.392 ms) : 0, 8392
IAST [baseline] (30.109 ms) : 0, 30109
IAST [candidate] (32.986 ms) : 0, 32986
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/gateway-inferred-span2
git_commit_date 1755723343 1755762733
git_commit_sha 5aa25ba e8c2baf
release_version 1.53.0-SNAPSHOT~5aa25baa32 1.53.0-SNAPSHOT~e8c2bafaff
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1755764260 1755764260
ci_job_id 1091335705 1091335705
ci_pipeline_id 74337849 74337849
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-rkp00vel 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-rkp00vel 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 1 performance improvements and 2 performance regressions! Performance is the same for 9 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:tracing:high_load worse
[+251.835µs; +488.253µs] or [+3.413%; +6.617%]
unstable
[-107.223op/s; +47.973op/s] or [-17.096%; +7.649%]
7.749ms 597.562op/s 7.379ms 627.188op/s
scenario:load:insecure-bank:iast:high_load better
[-643.823µs; -312.526µs] or [-6.675%; -3.240%]
unstable
[-34.122op/s; +83.622op/s] or [-7.088%; +17.370%]
9.167ms 506.156op/s 9.645ms 481.406op/s
scenario:load:petclinic:profiling:high_load worse
[+1.277ms; +2.296ms] or [+2.643%; +4.752%]
unstable
[-10.761op/s; +3.861op/s] or [-11.111%; +3.987%]
50.101ms 93.400op/s 48.315ms 96.850op/s
Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32
    dateFormat X
    axisFormat %s
section baseline
no_agent (4.346 ms) : 4295, 4396
.   : milestone, 4346,
iast (9.645 ms) : 9486, 9804
.   : milestone, 9645,
iast_FULL (13.939 ms) : 13663, 14216
.   : milestone, 13939,
iast_GLOBAL (10.416 ms) : 10236, 10597
.   : milestone, 10416,
profiling (8.771 ms) : 8636, 8907
.   : milestone, 8771,
tracing (7.379 ms) : 7277, 7481
.   : milestone, 7379,
section candidate
no_agent (4.37 ms) : 4318, 4421
.   : milestone, 4370,
iast (9.167 ms) : 9018, 9315
.   : milestone, 9167,
iast_FULL (13.825 ms) : 13547, 14102
.   : milestone, 13825,
iast_GLOBAL (10.396 ms) : 10213, 10578
.   : milestone, 10396,
profiling (8.916 ms) : 8777, 9054
.   : milestone, 8916,
tracing (7.749 ms) : 7632, 7866
.   : milestone, 7749,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 4.346 ms [4.295 ms, 4.396 ms] -
iast 9.645 ms [9.486 ms, 9.804 ms] 5.299 ms (121.9%)
iast_FULL 13.939 ms [13.663 ms, 14.216 ms] 9.594 ms (220.8%)
iast_GLOBAL 10.416 ms [10.236 ms, 10.597 ms] 6.07 ms (139.7%)
profiling 8.771 ms [8.636 ms, 8.907 ms] 4.426 ms (101.8%)
tracing 7.379 ms [7.277 ms, 7.481 ms] 3.033 ms (69.8%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 4.37 ms [4.318 ms, 4.421 ms] -
iast 9.167 ms [9.018 ms, 9.315 ms] 4.797 ms (109.8%)
iast_FULL 13.825 ms [13.547 ms, 14.102 ms] 9.455 ms (216.4%)
iast_GLOBAL 10.396 ms [10.213 ms, 10.578 ms] 6.026 ms (137.9%)
profiling 8.916 ms [8.777 ms, 9.054 ms] 4.546 ms (104.0%)
tracing 7.749 ms [7.632 ms, 7.866 ms] 3.379 ms (77.3%)
Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32
    dateFormat X
    axisFormat %s
section baseline
no_agent (36.728 ms) : 36427, 37030
.   : milestone, 36728,
appsec (48.322 ms) : 47891, 48752
.   : milestone, 48322,
code_origins (45.791 ms) : 45398, 46185
.   : milestone, 45791,
iast (44.063 ms) : 43703, 44424
.   : milestone, 44063,
profiling (48.315 ms) : 47863, 48767
.   : milestone, 48315,
tracing (43.912 ms) : 43553, 44271
.   : milestone, 43912,
section candidate
no_agent (37.201 ms) : 36904, 37497
.   : milestone, 37201,
appsec (48.465 ms) : 48042, 48888
.   : milestone, 48465,
code_origins (46.555 ms) : 46152, 46958
.   : milestone, 46555,
iast (43.907 ms) : 43533, 44280
.   : milestone, 43907,
profiling (50.101 ms) : 49607, 50595
.   : milestone, 50101,
tracing (44.751 ms) : 44366, 45136
.   : milestone, 44751,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 36.728 ms [36.427 ms, 37.03 ms] -
appsec 48.322 ms [47.891 ms, 48.752 ms] 11.593 ms (31.6%)
code_origins 45.791 ms [45.398 ms, 46.185 ms] 9.063 ms (24.7%)
iast 44.063 ms [43.703 ms, 44.424 ms] 7.335 ms (20.0%)
profiling 48.315 ms [47.863 ms, 48.767 ms] 11.587 ms (31.5%)
tracing 43.912 ms [43.553 ms, 44.271 ms] 7.184 ms (19.6%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 37.201 ms [36.904 ms, 37.497 ms] -
appsec 48.465 ms [48.042 ms, 48.888 ms] 11.264 ms (30.3%)
code_origins 46.555 ms [46.152 ms, 46.958 ms] 9.354 ms (25.1%)
iast 43.907 ms [43.533 ms, 44.28 ms] 6.706 ms (18.0%)
profiling 50.101 ms [49.607 ms, 50.595 ms] 12.901 ms (34.7%)
tracing 44.751 ms [44.366 ms, 45.136 ms] 7.55 ms (20.3%)

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master bbujon/gateway-inferred-span2
git_commit_date 1755723343 1755762733
git_commit_sha 5aa25ba e8c2baf
release_version 1.53.0-SNAPSHOT~5aa25baa32 1.53.0-SNAPSHOT~e8c2bafaff
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1755764743 1755764743
ci_job_id 1091335706 1091335706
ci_pipeline_id 74337849 74337849
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-xa2ktszx 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-xa2ktszx 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 biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32
    dateFormat X
    axisFormat %s
section baseline
no_agent (14.99 s) : 14990000, 14990000
.   : milestone, 14990000,
appsec (15.005 s) : 15005000, 15005000
.   : milestone, 15005000,
iast (18.444 s) : 18444000, 18444000
.   : milestone, 18444000,
iast_GLOBAL (18.295 s) : 18295000, 18295000
.   : milestone, 18295000,
profiling (15.298 s) : 15298000, 15298000
.   : milestone, 15298000,
tracing (15.049 s) : 15049000, 15049000
.   : milestone, 15049000,
section candidate
no_agent (15.54 s) : 15540000, 15540000
.   : milestone, 15540000,
appsec (15.044 s) : 15044000, 15044000
.   : milestone, 15044000,
iast (18.778 s) : 18778000, 18778000
.   : milestone, 18778000,
iast_GLOBAL (17.998 s) : 17998000, 17998000
.   : milestone, 17998000,
profiling (15.083 s) : 15083000, 15083000
.   : milestone, 15083000,
tracing (14.789 s) : 14789000, 14789000
.   : milestone, 14789000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.99 s [14.99 s, 14.99 s] -
appsec 15.005 s [15.005 s, 15.005 s] 15.0 ms (0.1%)
iast 18.444 s [18.444 s, 18.444 s] 3.454 s (23.0%)
iast_GLOBAL 18.295 s [18.295 s, 18.295 s] 3.305 s (22.0%)
profiling 15.298 s [15.298 s, 15.298 s] 308.0 ms (2.1%)
tracing 15.049 s [15.049 s, 15.049 s] 59.0 ms (0.4%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 15.54 s [15.54 s, 15.54 s] -
appsec 15.044 s [15.044 s, 15.044 s] -496.0 ms (-3.2%)
iast 18.778 s [18.778 s, 18.778 s] 3.238 s (20.8%)
iast_GLOBAL 17.998 s [17.998 s, 17.998 s] 2.458 s (15.8%)
profiling 15.083 s [15.083 s, 15.083 s] -457.0 ms (-2.9%)
tracing 14.789 s [14.789 s, 14.789 s] -751.0 ms (-4.8%)
Execution time for tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.53.0-SNAPSHOT~e8c2bafaff, baseline=1.53.0-SNAPSHOT~5aa25baa32
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.473 ms) : 1462, 1485
.   : milestone, 1473,
appsec (2.417 ms) : 2367, 2467
.   : milestone, 2417,
iast (2.199 ms) : 2136, 2262
.   : milestone, 2199,
iast_GLOBAL (2.236 ms) : 2173, 2299
.   : milestone, 2236,
profiling (2.047 ms) : 1997, 2097
.   : milestone, 2047,
tracing (2.025 ms) : 1976, 2074
.   : milestone, 2025,
section candidate
no_agent (1.473 ms) : 1462, 1485
.   : milestone, 1473,
appsec (3.671 ms) : 3454, 3888
.   : milestone, 3671,
iast (2.197 ms) : 2134, 2260
.   : milestone, 2197,
iast_GLOBAL (2.24 ms) : 2177, 2303
.   : milestone, 2240,
profiling (2.042 ms) : 1991, 2093
.   : milestone, 2042,
tracing (2.023 ms) : 1974, 2072
.   : milestone, 2023,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.473 ms [1.462 ms, 1.485 ms] -
appsec 2.417 ms [2.367 ms, 2.467 ms] 943.648 µs (64.1%)
iast 2.199 ms [2.136 ms, 2.262 ms] 725.813 µs (49.3%)
iast_GLOBAL 2.236 ms [2.173 ms, 2.299 ms] 762.769 µs (51.8%)
profiling 2.047 ms [1.997 ms, 2.097 ms] 573.815 µs (38.9%)
tracing 2.025 ms [1.976 ms, 2.074 ms] 552.165 µs (37.5%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.473 ms [1.462 ms, 1.485 ms] -
appsec 3.671 ms [3.454 ms, 3.888 ms] 2.197 ms (149.2%)
iast 2.197 ms [2.134 ms, 2.26 ms] 723.97 µs (49.1%)
iast_GLOBAL 2.24 ms [2.177 ms, 2.303 ms] 766.901 µs (52.1%)
profiling 2.042 ms [1.991 ms, 2.093 ms] 568.681 µs (38.6%)
tracing 2.023 ms [1.974 ms, 2.072 ms] 549.458 µs (37.3%)

@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
* Creates inferred proxy spans for API Gateway calls via presence of http headers

---------

Co-authored-by: Zarir Hamza <[email protected]>
@PerfectSlayer PerfectSlayer force-pushed the bbujon/gateway-inferred-span2 branch from 8e4e88b to ad6356f Compare August 21, 2025 07:49
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 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 +70
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.

@PerfectSlayer PerfectSlayer enabled auto-merge (squash) August 29, 2025 07:57
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.

3 participants