-
Notifications
You must be signed in to change notification settings - Fork 284
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
Inject trace context into EventBridge detail #7613
base: master
Are you sure you want to change the base?
Conversation
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Outdated
Show resolved
Hide resolved
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 49 metrics, 14 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.066 s) : 0, 1066126
Total [baseline] (8.54 s) : 0, 8540038
Agent [candidate] (1.065 s) : 0, 1064644
Total [candidate] (8.545 s) : 0, 8545339
section iast
Agent [baseline] (1.197 s) : 0, 1197339
Total [baseline] (9.037 s) : 0, 9037232
Agent [candidate] (1.19 s) : 0, 1189668
Total [candidate] (9.042 s) : 0, 9042329
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.196 s) : 0, 1196499
Total [baseline] (9.014 s) : 0, 9013977
Agent [candidate] (1.192 s) : 0, 1191934
Total [candidate] (9.016 s) : 0, 9016429
section iast_TELEMETRY_OFF
Agent [baseline] (1.193 s) : 0, 1192636
Total [baseline] (9.008 s) : 0, 9008479
Agent [candidate] (1.184 s) : 0, 1183850
Total [candidate] (8.972 s) : 0, 8972313
gantt
title insecure-bank - break down per module: candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (681.062 ms) : 0, 681062
BytebuddyAgent [candidate] (679.557 ms) : 0, 679557
GlobalTracer [baseline] (309.494 ms) : 0, 309494
GlobalTracer [candidate] (309.66 ms) : 0, 309660
AppSec [baseline] (53.748 ms) : 0, 53748
AppSec [candidate] (53.651 ms) : 0, 53651
Remote Config [baseline] (662.187 µs) : 0, 662
Remote Config [candidate] (667.532 µs) : 0, 668
Telemetry [baseline] (7.548 ms) : 0, 7548
Telemetry [candidate] (7.553 ms) : 0, 7553
section iast
BytebuddyAgent [baseline] (797.353 ms) : 0, 797353
BytebuddyAgent [candidate] (792.342 ms) : 0, 792342
GlobalTracer [baseline] (299.919 ms) : 0, 299919
GlobalTracer [candidate] (298.207 ms) : 0, 298207
AppSec [baseline] (55.789 ms) : 0, 55789
AppSec [candidate] (53.209 ms) : 0, 53209
IAST [baseline] (22.858 ms) : 0, 22858
IAST [candidate] (24.518 ms) : 0, 24518
Remote Config [baseline] (647.385 µs) : 0, 647
Remote Config [candidate] (647.539 µs) : 0, 648
Telemetry [baseline] (7.08 ms) : 0, 7080
Telemetry [candidate] (7.114 ms) : 0, 7114
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (796.634 ms) : 0, 796634
BytebuddyAgent [candidate] (793.242 ms) : 0, 793242
GlobalTracer [baseline] (299.653 ms) : 0, 299653
GlobalTracer [candidate] (298.61 ms) : 0, 298610
AppSec [baseline] (54.355 ms) : 0, 54355
AppSec [candidate] (54.984 ms) : 0, 54984
IAST [baseline] (24.456 ms) : 0, 24456
IAST [candidate] (23.713 ms) : 0, 23713
Remote Config [baseline] (619.538 µs) : 0, 620
Remote Config [candidate] (634.436 µs) : 0, 634
Telemetry [baseline] (7.051 ms) : 0, 7051
Telemetry [candidate] (7.1 ms) : 0, 7100
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (793.254 ms) : 0, 793254
BytebuddyAgent [candidate] (787.358 ms) : 0, 787358
GlobalTracer [baseline] (300.107 ms) : 0, 300107
GlobalTracer [candidate] (298.583 ms) : 0, 298583
AppSec [baseline] (55.602 ms) : 0, 55602
AppSec [candidate] (55.432 ms) : 0, 55432
IAST [baseline] (21.705 ms) : 0, 21705
IAST [candidate] (21.388 ms) : 0, 21388
Remote Config [baseline] (1.36 ms) : 0, 1360
Remote Config [candidate] (597.263 µs) : 0, 597
Telemetry [baseline] (6.904 ms) : 0, 6904
Telemetry [candidate] (6.811 ms) : 0, 6811
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.064 s) : 0, 1063925
Total [baseline] (10.314 s) : 0, 10314401
Agent [candidate] (1.073 s) : 0, 1073047
Total [candidate] (10.479 s) : 0, 10478611
section appsec
Agent [baseline] (1.2 s) : 0, 1200426
Total [baseline] (10.58 s) : 0, 10579607
Agent [candidate] (1.212 s) : 0, 1212440
Total [candidate] (10.666 s) : 0, 10665626
section iast
Agent [baseline] (1.188 s) : 0, 1188286
Total [baseline] (10.736 s) : 0, 10736232
Agent [candidate] (1.191 s) : 0, 1190876
Total [candidate] (10.813 s) : 0, 10812768
section profiling
Agent [baseline] (1.265 s) : 0, 1264845
Total [baseline] (10.549 s) : 0, 10549331
Agent [candidate] (1.26 s) : 0, 1260197
Total [candidate] (10.623 s) : 0, 10622862
gantt
title petclinic - break down per module: candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (679.192 ms) : 0, 679192
BytebuddyAgent [candidate] (684.975 ms) : 0, 684975
GlobalTracer [baseline] (309.316 ms) : 0, 309316
GlobalTracer [candidate] (311.924 ms) : 0, 311924
AppSec [baseline] (53.628 ms) : 0, 53628
AppSec [candidate] (54.059 ms) : 0, 54059
Remote Config [baseline] (658.412 µs) : 0, 658
Remote Config [candidate] (668.788 µs) : 0, 669
Telemetry [baseline] (7.556 ms) : 0, 7556
Telemetry [candidate] (7.706 ms) : 0, 7706
section appsec
BytebuddyAgent [baseline] (702.504 ms) : 0, 702504
BytebuddyAgent [candidate] (707.645 ms) : 0, 707645
GlobalTracer [baseline] (302.741 ms) : 0, 302741
GlobalTracer [candidate] (306.76 ms) : 0, 306760
AppSec [baseline] (161.951 ms) : 0, 161951
AppSec [candidate] (165.414 ms) : 0, 165414
IAST [baseline] (19.665 ms) : 0, 19665
IAST [candidate] (20.111 ms) : 0, 20111
Remote Config [baseline] (642.956 µs) : 0, 643
Remote Config [candidate] (650.212 µs) : 0, 650
Telemetry [baseline] (9.142 ms) : 0, 9142
Telemetry [candidate] (8.204 ms) : 0, 8204
section iast
BytebuddyAgent [baseline] (791.473 ms) : 0, 791473
BytebuddyAgent [candidate] (792.927 ms) : 0, 792927
GlobalTracer [baseline] (297.963 ms) : 0, 297963
GlobalTracer [candidate] (298.8 ms) : 0, 298800
AppSec [baseline] (53.389 ms) : 0, 53389
AppSec [candidate] (56.022 ms) : 0, 56022
IAST [baseline] (24.263 ms) : 0, 24263
IAST [candidate] (21.849 ms) : 0, 21849
Remote Config [baseline] (603.292 µs) : 0, 603
Remote Config [candidate] (604.665 µs) : 0, 605
Telemetry [baseline] (6.958 ms) : 0, 6958
Telemetry [candidate] (7.023 ms) : 0, 7023
section profiling
BytebuddyAgent [baseline] (674.117 ms) : 0, 674117
BytebuddyAgent [candidate] (672.536 ms) : 0, 672536
GlobalTracer [baseline] (393.548 ms) : 0, 393548
GlobalTracer [candidate] (391.609 ms) : 0, 391609
AppSec [baseline] (54.566 ms) : 0, 54566
AppSec [candidate] (54.134 ms) : 0, 54134
Remote Config [baseline] (649.688 µs) : 0, 650
Remote Config [candidate] (651.681 µs) : 0, 652
Telemetry [baseline] (7.444 ms) : 0, 7444
Telemetry [candidate] (7.384 ms) : 0, 7384
ProfilingAgent [baseline] (95.994 ms) : 0, 95994
ProfilingAgent [candidate] (95.46 ms) : 0, 95460
Profiling [baseline] (96.018 ms) : 0, 96018
Profiling [candidate] (95.484 ms) : 0, 95484
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 17 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section baseline
no_agent (369.73 µs) : 349, 390
. : milestone, 370,
iast (481.557 µs) : 460, 503
. : milestone, 482,
iast_FULL (548.737 µs) : 527, 570
. : milestone, 549,
iast_GLOBAL (509.841 µs) : 487, 532
. : milestone, 510,
iast_HARDCODED_SECRET_DISABLED (481.326 µs) : 460, 503
. : milestone, 481,
iast_INACTIVE (439.871 µs) : 419, 460
. : milestone, 440,
iast_TELEMETRY_OFF (475.405 µs) : 452, 498
. : milestone, 475,
tracing (439.655 µs) : 419, 460
. : milestone, 440,
section candidate
no_agent (377.012 µs) : 357, 397
. : milestone, 377,
iast (483.557 µs) : 462, 505
. : milestone, 484,
iast_FULL (549.142 µs) : 528, 570
. : milestone, 549,
iast_GLOBAL (501.813 µs) : 480, 524
. : milestone, 502,
iast_HARDCODED_SECRET_DISABLED (485.91 µs) : 464, 508
. : milestone, 486,
iast_INACTIVE (445.179 µs) : 424, 467
. : milestone, 445,
iast_TELEMETRY_OFF (475.621 µs) : 453, 498
. : milestone, 476,
tracing (435.321 µs) : 415, 456
. : milestone, 435,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section baseline
no_agent (1.338 ms) : 1319, 1358
. : milestone, 1338,
appsec (1.703 ms) : 1678, 1727
. : milestone, 1703,
appsec_no_iast (1.701 ms) : 1676, 1726
. : milestone, 1701,
iast (1.472 ms) : 1449, 1494
. : milestone, 1472,
profiling (1.465 ms) : 1442, 1488
. : milestone, 1465,
tracing (1.47 ms) : 1446, 1494
. : milestone, 1470,
section candidate
no_agent (1.342 ms) : 1323, 1361
. : milestone, 1342,
appsec (1.711 ms) : 1689, 1734
. : milestone, 1711,
appsec_no_iast (1.734 ms) : 1710, 1758
. : milestone, 1734,
iast (1.455 ms) : 1432, 1478
. : milestone, 1455,
profiling (1.507 ms) : 1481, 1533
. : milestone, 1507,
tracing (1.462 ms) : 1439, 1486
. : milestone, 1462,
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 tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section baseline
no_agent (1.47 ms) : 1459, 1482
. : milestone, 1470,
appsec (2.328 ms) : 2287, 2369
. : milestone, 2328,
iast (2.049 ms) : 2001, 2098
. : milestone, 2049,
iast_GLOBAL (2.107 ms) : 2057, 2158
. : milestone, 2107,
profiling (1.927 ms) : 1886, 1968
. : milestone, 1927,
tracing (1.905 ms) : 1867, 1943
. : milestone, 1905,
section candidate
no_agent (1.473 ms) : 1461, 1484
. : milestone, 1473,
appsec (2.337 ms) : 2296, 2378
. : milestone, 2337,
iast (2.049 ms) : 1999, 2099
. : milestone, 2049,
iast_GLOBAL (2.112 ms) : 2061, 2164
. : milestone, 2112,
profiling (1.931 ms) : 1890, 1972
. : milestone, 1931,
tracing (1.897 ms) : 1859, 1935
. : milestone, 1897,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~9cf207e605, baseline=1.40.0-SNAPSHOT~aa1e54c87a
dateFormat X
axisFormat %s
section baseline
no_agent (15.026 s) : 15026000, 15026000
. : milestone, 15026000,
appsec (15.107 s) : 15107000, 15107000
. : milestone, 15107000,
iast (19.04 s) : 19040000, 19040000
. : milestone, 19040000,
iast_GLOBAL (18.181 s) : 18181000, 18181000
. : milestone, 18181000,
profiling (15.126 s) : 15126000, 15126000
. : milestone, 15126000,
tracing (15.327 s) : 15327000, 15327000
. : milestone, 15327000,
section candidate
no_agent (15.852 s) : 15852000, 15852000
. : milestone, 15852000,
appsec (15.185 s) : 15185000, 15185000
. : milestone, 15185000,
iast (18.941 s) : 18941000, 18941000
. : milestone, 18941000,
iast_GLOBAL (17.977 s) : 17977000, 17977000
. : milestone, 17977000,
profiling (15.36 s) : 15360000, 15360000
. : milestone, 15360000,
tracing (15.221 s) : 15221000, 15221000
. : milestone, 15221000,
|
public static final String BUS_TAG = "bus"; | ||
private static final DDCache<String, String> BUS_TAG_CACHE = DDCaches.newFixedSizeCache(32); | ||
private static final Function<String, String> BUS_TAG_PREFIX = new StringPrefix("bus:"); |
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.
I'm actually not 100% sure what this does, but I was copying what the implementation for SNS did. Are these tags to be used by users for querying purposes, or does it do something else?
dd-trace-core/src/main/java/datadog/trace/lambda/MoshiJsonAdapter.java
Outdated
Show resolved
Hide resolved
internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java
Outdated
Show resolved
Hide resolved
.../java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeClientInstrumentation.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Outdated
Show resolved
Hide resolved
...0/src/main/java/datadog/trace/instrumentation/aws/v2/eventbridge/EventBridgeInterceptor.java
Outdated
Show resolved
Hide resolved
.../aws-java-sns-2.0/src/main/java/datadog/trace/instrumentation/aws/v2/sns/SnsInterceptor.java
Show resolved
Hide resolved
88b77fa
to
00be0b8
Compare
… env var. Add async client tests.
00be0b8
to
0aa00d0
Compare
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.
This looks good to me!
739383e
to
a409a15
Compare
Quick question about the new label: is EventBridge falls under AWS SDK? |
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.
LGTM
InstanceStore.of(ExecutionAttribute.class) | ||
.putIfAbsent("DatadogSpan", () -> new ExecutionAttribute<>("DatadogSpan")); | ||
|
||
private static final String DATADOG_KEY = "_datadog"; |
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.
Why wouldn't you rather use PathwayContext.DATADOG_KEY
?
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.
Good catch
Yes it does |
What Does This Do
This creates a new instrumentation for EventBridge and intercepts
PutEventsRequest
to inject trace context. This allows the agent to combine spans from a distributed (serverless) architecture into a single trace.This PR only injects trace context. I'm working on PR 1 and PR 2 to update the Lambda extension to use this trace context to create EventBridge spans.
Motivation
SNS and SQS are already supported, and the tracer currently injects trace context into message attributes fields for them. However, EventBridge wasn't supported, and this PR aims to fix this problem.
Additional Notes
Overall, AWS's EventBridge API is lacking some features, so we have to do some hacky solutions.
messageAttributes
, and EventBridge calls itdetail
detail
field is given as a raw string. Therefore, we have to manually modify thedetail
string using StringBuilder.detail[_datadog]
asx-datadog-start-time
detail[_datadog]
asx-datadog-resource-name
Traces before these changes
Lambda --> EventBridge --> Lambda
Two different traces. Second trace is missing an EventBridge span
Lambda --> EventBridge --> SQS --> Lambda
Missing EventBridge span
Lambda --> EventBridge --> SNS --> Lambda
Missing EventBridge span
Traces after these (and agent's) changes
Lambda --> EventBridge --> Lambda
Lambda --> EventBridge --> SQS --> Lambda
Lambda --> EventBridge --> SNS --> Lambda
Contributor Checklist
type:
and (comp:
orinst:
) labels in addition to any usefull labelsclose
,fix
or any linking keywords when referencing an issue.Use
solves
instead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]