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

Websocket: ensure that trace context is propagated from the handshake #8619

Merged
merged 2 commits into from
Mar 31, 2025

Conversation

amarziali
Copy link
Collaborator

@amarziali amarziali commented Mar 25, 2025

What Does This Do

According to the websocket RFC:

The trace context is extracted from the original http client or server upgrade.
Meaning any baggage, tags, origin, sampling decision on the trace context (i.e. what would be t, s and o of the tracestate as well as the baggage) are applied to any incoming message or websocket close span and propagated to downstream traces, but not span or trace ids.

This PR copies propagation tags from the handshake to receive or close spans that are opened in a new trace and locks the DM if it's inherited since it's a requirement for the intake

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added type: bug tag: no release notes Changes to exclude from release notes inst: websocket WebSocket Instrumentation labels Mar 25, 2025
@amarziali amarziali requested review from a team as code owners March 25, 2025 13:32
@amarziali amarziali requested review from smola and mcculls March 25, 2025 13:32
@pr-commenter
Copy link

pr-commenter bot commented Mar 25, 2025

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master andrea.marziali/websocket-propagate
git_commit_date 1743121790 1743147144
git_commit_sha 4a5461c ef2a423
release_version 1.48.0-SNAPSHOT~4a5461cf3e 1.48.0-SNAPSHOT~ef2a423c86
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1743150099 1743150099
ci_job_id 869358872 869358872
ci_pipeline_id 60289726 60289726
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-232sggg1-project-304-concurrent-0-1julbp6i 6.8.0-1024-aws #26~22.04.1-Ubuntu SMP Wed Feb 19 06:54:57 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-232sggg1-project-304-concurrent-0-1julbp6i 6.8.0-1024-aws #26~22.04.1-Ubuntu SMP Wed Feb 19 06:54:57 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
module Agent Agent
parent None None
variant iast iast

Summary

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

Startup time reports for petclinic
gantt
    title petclinic - global startup overhead: candidate=1.48.0-SNAPSHOT~ef2a423c86, baseline=1.48.0-SNAPSHOT~4a5461cf3e

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.049 s) : 0, 1049005
Total [baseline] (10.411 s) : 0, 10410532
Agent [candidate] (1.052 s) : 0, 1051917
Total [candidate] (10.407 s) : 0, 10406585
section appsec
Agent [baseline] (1.195 s) : 0, 1195312
Total [baseline] (10.725 s) : 0, 10725087
Agent [candidate] (1.195 s) : 0, 1194578
Total [candidate] (10.782 s) : 0, 10781502
section iast
Agent [baseline] (1.179 s) : 0, 1179046
Total [baseline] (11.068 s) : 0, 11067718
Agent [candidate] (1.189 s) : 0, 1188996
Total [candidate] (11.105 s) : 0, 11104522
section profiling
Agent [baseline] (1.273 s) : 0, 1273269
Total [baseline] (10.86 s) : 0, 10859539
Agent [candidate] (1.283 s) : 0, 1283114
Total [candidate] (10.876 s) : 0, 10876306
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.049 s -
Agent appsec 1.195 s 146.307 ms (13.9%)
Agent iast 1.179 s 130.042 ms (12.4%)
Agent profiling 1.273 s 224.264 ms (21.4%)
Total tracing 10.411 s -
Total appsec 10.725 s 314.555 ms (3.0%)
Total iast 11.068 s 657.185 ms (6.3%)
Total profiling 10.86 s 449.007 ms (4.3%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.052 s -
Agent appsec 1.195 s 142.661 ms (13.6%)
Agent iast 1.189 s 137.078 ms (13.0%)
Agent profiling 1.283 s 231.197 ms (22.0%)
Total tracing 10.407 s -
Total appsec 10.782 s 374.917 ms (3.6%)
Total iast 11.105 s 697.937 ms (6.7%)
Total profiling 10.876 s 469.721 ms (4.5%)
gantt
    title petclinic - break down per module: candidate=1.48.0-SNAPSHOT~ef2a423c86, baseline=1.48.0-SNAPSHOT~4a5461cf3e

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (718.556 ms) : 0, 718556
BytebuddyAgent [candidate] (718.519 ms) : 0, 718519
GlobalTracer [baseline] (238.744 ms) : 0, 238744
GlobalTracer [candidate] (238.792 ms) : 0, 238792
AppSec [baseline] (54.681 ms) : 0, 54681
AppSec [candidate] (54.899 ms) : 0, 54899
Debugger [baseline] (4.42 ms) : 0, 4420
Debugger [candidate] (5.156 ms) : 0, 5156
Remote Config [baseline] (695.376 µs) : 0, 695
Remote Config [candidate] (692.49 µs) : 0, 692
Telemetry [baseline] (12.196 ms) : 0, 12196
Telemetry [candidate] (14.239 ms) : 0, 14239
section appsec
BytebuddyAgent [baseline] (739.201 ms) : 0, 739201
BytebuddyAgent [candidate] (738.554 ms) : 0, 738554
GlobalTracer [baseline] (235.72 ms) : 0, 235720
GlobalTracer [candidate] (235.76 ms) : 0, 235760
IAST [baseline] (21.778 ms) : 0, 21778
IAST [candidate] (21.679 ms) : 0, 21679
AppSec [baseline] (176.638 ms) : 0, 176638
AppSec [candidate] (176.137 ms) : 0, 176137
Debugger [baseline] (4.297 ms) : 0, 4297
Debugger [candidate] (4.301 ms) : 0, 4301
Remote Config [baseline] (647.42 µs) : 0, 647
Remote Config [candidate] (648.317 µs) : 0, 648
Telemetry [baseline] (8.181 ms) : 0, 8181
Telemetry [candidate] (8.597 ms) : 0, 8597
section iast
BytebuddyAgent [baseline] (837.605 ms) : 0, 837605
BytebuddyAgent [candidate] (844.232 ms) : 0, 844232
GlobalTracer [baseline] (229.029 ms) : 0, 229029
GlobalTracer [candidate] (231.839 ms) : 0, 231839
IAST [baseline] (23.008 ms) : 0, 23008
IAST [candidate] (23.176 ms) : 0, 23176
AppSec [baseline] (55.975 ms) : 0, 55975
AppSec [candidate] (56.47 ms) : 0, 56470
Debugger [baseline] (4.212 ms) : 0, 4212
Debugger [candidate] (4.194 ms) : 0, 4194
Remote Config [baseline] (625.388 µs) : 0, 625
Remote Config [candidate] (620.306 µs) : 0, 620
Telemetry [baseline] (8.942 ms) : 0, 8942
Telemetry [candidate] (8.802 ms) : 0, 8802
section profiling
BytebuddyAgent [baseline] (709.692 ms) : 0, 709692
BytebuddyAgent [candidate] (715.614 ms) : 0, 715614
GlobalTracer [baseline] (348.477 ms) : 0, 348477
GlobalTracer [candidate] (350.91 ms) : 0, 350910
AppSec [baseline] (53.95 ms) : 0, 53950
AppSec [candidate] (53.637 ms) : 0, 53637
Debugger [baseline] (4.259 ms) : 0, 4259
Debugger [candidate] (4.287 ms) : 0, 4287
Remote Config [baseline] (701.354 µs) : 0, 701
Remote Config [candidate] (699.943 µs) : 0, 700
Telemetry [baseline] (8.911 ms) : 0, 8911
Telemetry [candidate] (8.946 ms) : 0, 8946
ProfilingAgent [baseline] (102.401 ms) : 0, 102401
ProfilingAgent [candidate] (103.802 ms) : 0, 103802
Profiling [baseline] (102.428 ms) : 0, 102428
Profiling [candidate] (103.827 ms) : 0, 103827
Loading
Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.48.0-SNAPSHOT~ef2a423c86, baseline=1.48.0-SNAPSHOT~4a5461cf3e

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.054 s) : 0, 1053787
Total [baseline] (8.678 s) : 0, 8677978
Agent [candidate] (1.061 s) : 0, 1060578
Total [candidate] (8.71 s) : 0, 8710290
section iast
Agent [baseline] (1.185 s) : 0, 1184679
Total [baseline] (9.335 s) : 0, 9335428
Agent [candidate] (1.184 s) : 0, 1183734
Total [candidate] (9.262 s) : 0, 9261967
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.176 s) : 0, 1175878
Total [baseline] (9.19 s) : 0, 9189980
Agent [candidate] (1.181 s) : 0, 1181340
Total [candidate] (9.217 s) : 0, 9217470
section iast_TELEMETRY_OFF
Agent [baseline] (1.181 s) : 0, 1181142
Total [baseline] (9.28 s) : 0, 9279591
Agent [candidate] (1.176 s) : 0, 1176431
Total [candidate] (9.255 s) : 0, 9255269
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.054 s -
Agent iast 1.185 s 130.892 ms (12.4%)
Agent iast_HARDCODED_SECRET_DISABLED 1.176 s 122.091 ms (11.6%)
Agent iast_TELEMETRY_OFF 1.181 s 127.354 ms (12.1%)
Total tracing 8.678 s -
Total iast 9.335 s 657.45 ms (7.6%)
Total iast_HARDCODED_SECRET_DISABLED 9.19 s 512.003 ms (5.9%)
Total iast_TELEMETRY_OFF 9.28 s 601.613 ms (6.9%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.061 s -
Agent iast 1.184 s 123.155 ms (11.6%)
Agent iast_HARDCODED_SECRET_DISABLED 1.181 s 120.762 ms (11.4%)
Agent iast_TELEMETRY_OFF 1.176 s 115.853 ms (10.9%)
Total tracing 8.71 s -
Total iast 9.262 s 551.677 ms (6.3%)
Total iast_HARDCODED_SECRET_DISABLED 9.217 s 507.181 ms (5.8%)
Total iast_TELEMETRY_OFF 9.255 s 544.979 ms (6.3%)
gantt
    title insecure-bank - break down per module: candidate=1.48.0-SNAPSHOT~ef2a423c86, baseline=1.48.0-SNAPSHOT~4a5461cf3e

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (721.78 ms) : 0, 721780
BytebuddyAgent [candidate] (726.087 ms) : 0, 726087
GlobalTracer [baseline] (239.945 ms) : 0, 239945
GlobalTracer [candidate] (241.67 ms) : 0, 241670
AppSec [baseline] (54.92 ms) : 0, 54920
AppSec [candidate] (55.05 ms) : 0, 55050
Debugger [baseline] (5.135 ms) : 0, 5135
Debugger [candidate] (6.667 ms) : 0, 6667
Remote Config [baseline] (708.524 µs) : 0, 709
Remote Config [candidate] (697.278 µs) : 0, 697
Telemetry [baseline] (11.473 ms) : 0, 11473
Telemetry [candidate] (10.593 ms) : 0, 10593
section iast
BytebuddyAgent [baseline] (842.79 ms) : 0, 842790
BytebuddyAgent [candidate] (840.549 ms) : 0, 840549
GlobalTracer [baseline] (229.686 ms) : 0, 229686
GlobalTracer [candidate] (230.673 ms) : 0, 230673
IAST [baseline] (22.765 ms) : 0, 22765
IAST [candidate] (22.952 ms) : 0, 22952
AppSec [baseline] (55.999 ms) : 0, 55999
AppSec [candidate] (56.211 ms) : 0, 56211
Debugger [baseline] (4.211 ms) : 0, 4211
Debugger [candidate] (4.195 ms) : 0, 4195
Remote Config [baseline] (623.399 µs) : 0, 623
Remote Config [candidate] (621.7 µs) : 0, 622
Telemetry [baseline] (8.92 ms) : 0, 8920
Telemetry [candidate] (8.854 ms) : 0, 8854
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (835.822 ms) : 0, 835822
BytebuddyAgent [candidate] (839.16 ms) : 0, 839160
GlobalTracer [baseline] (228.574 ms) : 0, 228574
GlobalTracer [candidate] (229.619 ms) : 0, 229619
IAST [baseline] (22.758 ms) : 0, 22758
IAST [candidate] (22.933 ms) : 0, 22933
AppSec [baseline] (55.765 ms) : 0, 55765
AppSec [candidate] (56.397 ms) : 0, 56397
Debugger [baseline] (4.122 ms) : 0, 4122
Debugger [candidate] (4.214 ms) : 0, 4214
Remote Config [baseline] (594.255 µs) : 0, 594
Remote Config [candidate] (598.151 µs) : 0, 598
Telemetry [baseline] (8.652 ms) : 0, 8652
Telemetry [candidate] (8.74 ms) : 0, 8740
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (839.817 ms) : 0, 839817
BytebuddyAgent [candidate] (835.995 ms) : 0, 835995
GlobalTracer [baseline] (229.142 ms) : 0, 229142
GlobalTracer [candidate] (228.994 ms) : 0, 228994
IAST [baseline] (22.526 ms) : 0, 22526
IAST [candidate] (22.451 ms) : 0, 22451
AppSec [baseline] (56.426 ms) : 0, 56426
AppSec [candidate] (55.774 ms) : 0, 55774
Debugger [baseline] (4.182 ms) : 0, 4182
Debugger [candidate] (4.179 ms) : 0, 4179
Remote Config [baseline] (615.058 µs) : 0, 615
Remote Config [candidate] (612.233 µs) : 0, 612
Telemetry [baseline] (8.698 ms) : 0, 8698
Telemetry [candidate] (8.777 ms) : 0, 8777
Loading

Load

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master andrea.marziali/websocket-propagate
git_commit_date 1743121790 1743147144
git_commit_sha 4a5461c ef2a423
release_version 1.48.0-SNAPSHOT~4a5461cf3e 1.48.0-SNAPSHOT~ef2a423c86
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1743149619 1743149619
ci_job_id 869358874 869358874
ci_pipeline_id 60289726 60289726
cpu_model Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
kernel_version Linux runner-232sggg1-project-304-concurrent-1-u5qeuodl 6.8.0-1024-aws #26~22.04.1-Ubuntu SMP Wed Feb 19 06:54:57 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux Linux runner-232sggg1-project-304-concurrent-1-u5qeuodl 6.8.0-1024-aws #26~22.04.1-Ubuntu SMP Wed Feb 19 06:54:57 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
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 tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.48.0-SNAPSHOT~ef2a423c86, baseline=1.48.0-SNAPSHOT~4a5461cf3e
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.476 ms) : 1465, 1488
.   : milestone, 1476,
appsec (2.354 ms) : 2310, 2398
.   : milestone, 2354,
iast (2.122 ms) : 2067, 2177
.   : milestone, 2122,
iast_GLOBAL (2.169 ms) : 2113, 2225
.   : milestone, 2169,
profiling (1.975 ms) : 1931, 2019
.   : milestone, 1975,
tracing (1.957 ms) : 1915, 2000
.   : milestone, 1957,
section candidate
no_agent (1.476 ms) : 1464, 1487
.   : milestone, 1476,
appsec (2.351 ms) : 2308, 2395
.   : milestone, 2351,
iast (2.134 ms) : 2079, 2190
.   : milestone, 2134,
iast_GLOBAL (2.161 ms) : 2105, 2217
.   : milestone, 2161,
profiling (2.001 ms) : 1955, 2046
.   : milestone, 2001,
tracing (1.973 ms) : 1930, 2016
.   : milestone, 1973,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.476 ms [1.465 ms, 1.488 ms] -
appsec 2.354 ms [2.31 ms, 2.398 ms] 878.102 µs (59.5%)
iast 2.122 ms [2.067 ms, 2.177 ms] 645.469 µs (43.7%)
iast_GLOBAL 2.169 ms [2.113 ms, 2.225 ms] 692.909 µs (46.9%)
profiling 1.975 ms [1.931 ms, 2.019 ms] 498.634 µs (33.8%)
tracing 1.957 ms [1.915 ms, 2.0 ms] 481.05 µs (32.6%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.476 ms [1.464 ms, 1.487 ms] -
appsec 2.351 ms [2.308 ms, 2.395 ms] 875.82 µs (59.4%)
iast 2.134 ms [2.079 ms, 2.19 ms] 658.546 µs (44.6%)
iast_GLOBAL 2.161 ms [2.105 ms, 2.217 ms] 685.432 µs (46.5%)
profiling 2.001 ms [1.955 ms, 2.046 ms] 524.987 µs (35.6%)
tracing 1.973 ms [1.93 ms, 2.016 ms] 497.096 µs (33.7%)
Execution time for biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.48.0-SNAPSHOT~ef2a423c86, baseline=1.48.0-SNAPSHOT~4a5461cf3e
    dateFormat X
    axisFormat %s
section baseline
no_agent (14.937 s) : 14937000, 14937000
.   : milestone, 14937000,
appsec (15.079 s) : 15079000, 15079000
.   : milestone, 15079000,
iast (18.896 s) : 18896000, 18896000
.   : milestone, 18896000,
iast_GLOBAL (18.18 s) : 18180000, 18180000
.   : milestone, 18180000,
profiling (15.125 s) : 15125000, 15125000
.   : milestone, 15125000,
tracing (15.078 s) : 15078000, 15078000
.   : milestone, 15078000,
section candidate
no_agent (15.653 s) : 15653000, 15653000
.   : milestone, 15653000,
appsec (14.832 s) : 14832000, 14832000
.   : milestone, 14832000,
iast (18.974 s) : 18974000, 18974000
.   : milestone, 18974000,
iast_GLOBAL (18.144 s) : 18144000, 18144000
.   : milestone, 18144000,
profiling (14.873 s) : 14873000, 14873000
.   : milestone, 14873000,
tracing (15.195 s) : 15195000, 15195000
.   : milestone, 15195000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.937 s [14.937 s, 14.937 s] -
appsec 15.079 s [15.079 s, 15.079 s] 142.0 ms (1.0%)
iast 18.896 s [18.896 s, 18.896 s] 3.959 s (26.5%)
iast_GLOBAL 18.18 s [18.18 s, 18.18 s] 3.243 s (21.7%)
profiling 15.125 s [15.125 s, 15.125 s] 188.0 ms (1.3%)
tracing 15.078 s [15.078 s, 15.078 s] 141.0 ms (0.9%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 15.653 s [15.653 s, 15.653 s] -
appsec 14.832 s [14.832 s, 14.832 s] -821.0 ms (-5.2%)
iast 18.974 s [18.974 s, 18.974 s] 3.321 s (21.2%)
iast_GLOBAL 18.144 s [18.144 s, 18.144 s] 2.491 s (15.9%)
profiling 14.873 s [14.873 s, 14.873 s] -780.0 ms (-5.0%)
tracing 15.195 s [15.195 s, 15.195 s] -458.0 ms (-2.9%)

@amarziali amarziali added inst: websocket WebSocket Instrumentation and removed inst: websocket WebSocket Instrumentation labels Mar 25, 2025
@amarziali amarziali force-pushed the andrea.marziali/websocket-propagate branch from c5d3158 to f67f0a8 Compare March 26, 2025 14:59
@@ -192,6 +192,10 @@ default AgentSpan asAgentSpan() {
return this;
}

default void copyPropagationAndBaggage(final AgentSpan source) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Code Quality Violation

Suggested change
default void copyPropagationAndBaggage(final AgentSpan source) {
default void copyPropagationAndBaggage(AgentSpan source) {
Avoid declaring as final as it may not be used (...read more)

The rule "Avoid useless final type in interface method" advises against the unnecessary use of the final keyword in the method parameters of an interface. In Java, the final keyword is used to denote that a variable cannot be changed once assigned. However, in the context of an interface method, this is redundant as the value of the parameter cannot be changed within the method anyway.

The importance of this rule lies in the clarity and simplicity of code. Unnecessary use of final in this context can lead to confusion for those reading the code, as it suggests that there may be a specific reason for its use when there is not. It can also clutter the code, making it less readable.

Good coding practices to avoid this rule violation include simply not using the final keyword in the method parameters of an interface. This does not affect the functionality of the code, but it makes it cleaner and easier to understand. For example, instead of writing void process(final Object arg);, you can write void process(Object arg);. This maintains the same functionality but improves the readability of the code.

View in Datadog  Leave us feedback  Documentation

Copy link
Contributor

@mcculls mcculls left a comment

Choose a reason for hiding this comment

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

Looks reasonable

@amarziali amarziali merged commit bfdfd2b into master Mar 31, 2025
261 of 268 checks passed
@amarziali amarziali deleted the andrea.marziali/websocket-propagate branch March 31, 2025 12:27
@github-actions github-actions bot added this to the 1.48.0 milestone Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inst: websocket WebSocket Instrumentation tag: no release notes Changes to exclude from release notes type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants