-
Notifications
You must be signed in to change notification settings - Fork 293
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
Create DynamoDB instrumentation + add span pointers for updateItem
and deleteItem
#8490
Conversation
# Conflicts: # dd-java-agent/instrumentation/aws-java-s3-2.0/src/main/java/datadog/trace/instrumentation/aws/v2/s3/TextMapInjectAdapter.java
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 58 metrics, 5 unstable metrics. Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.04 s) : 0, 1039737
Total [baseline] (8.68 s) : 0, 8680289
Agent [candidate] (1.036 s) : 0, 1035564
Total [candidate] (8.681 s) : 0, 8681393
section iast
Agent [baseline] (1.175 s) : 0, 1175185
Total [baseline] (9.222 s) : 0, 9222068
Agent [candidate] (1.17 s) : 0, 1169903
Total [candidate] (9.243 s) : 0, 9242891
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.167 s) : 0, 1166726
Total [baseline] (9.204 s) : 0, 9204053
Agent [candidate] (1.17 s) : 0, 1169677
Total [candidate] (9.208 s) : 0, 9207795
section iast_TELEMETRY_OFF
Agent [baseline] (1.171 s) : 0, 1171115
Total [baseline] (9.265 s) : 0, 9265081
Agent [candidate] (1.168 s) : 0, 1167592
Total [candidate] (9.226 s) : 0, 9226461
gantt
title insecure-bank - break down per module: candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (716.332 ms) : 0, 716332
BytebuddyAgent [candidate] (715.266 ms) : 0, 715266
GlobalTracer [baseline] (239.086 ms) : 0, 239086
GlobalTracer [candidate] (238.825 ms) : 0, 238825
AppSec [baseline] (54.996 ms) : 0, 54996
AppSec [candidate] (55.246 ms) : 0, 55246
Remote Config [baseline] (679.905 µs) : 0, 680
Remote Config [candidate] (674.486 µs) : 0, 674
Telemetry [baseline] (13.708 ms) : 0, 13708
Telemetry [candidate] (10.614 ms) : 0, 10614
section iast
BytebuddyAgent [baseline] (840.542 ms) : 0, 840542
BytebuddyAgent [candidate] (836.59 ms) : 0, 836590
GlobalTracer [baseline] (230.97 ms) : 0, 230970
GlobalTracer [candidate] (230.01 ms) : 0, 230010
IAST [baseline] (23.672 ms) : 0, 23672
IAST [candidate] (22.799 ms) : 0, 22799
AppSec [baseline] (55.658 ms) : 0, 55658
AppSec [candidate] (56.358 ms) : 0, 56358
Remote Config [baseline] (608.051 µs) : 0, 608
Remote Config [candidate] (602.664 µs) : 0, 603
Telemetry [baseline] (8.619 ms) : 0, 8619
Telemetry [candidate] (8.63 ms) : 0, 8630
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (833.238 ms) : 0, 833238
BytebuddyAgent [candidate] (835.669 ms) : 0, 835669
GlobalTracer [baseline] (229.678 ms) : 0, 229678
GlobalTracer [candidate] (230.029 ms) : 0, 230029
IAST [baseline] (22.953 ms) : 0, 22953
IAST [candidate] (22.981 ms) : 0, 22981
AppSec [baseline] (56.652 ms) : 0, 56652
AppSec [candidate] (56.77 ms) : 0, 56770
Remote Config [baseline] (606.154 µs) : 0, 606
Remote Config [candidate] (608.304 µs) : 0, 608
Telemetry [baseline] (8.664 ms) : 0, 8664
Telemetry [candidate] (8.69 ms) : 0, 8690
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (836.922 ms) : 0, 836922
BytebuddyAgent [candidate] (833.616 ms) : 0, 833616
GlobalTracer [baseline] (230.519 ms) : 0, 230519
GlobalTracer [candidate] (230.27 ms) : 0, 230270
IAST [baseline] (23.2 ms) : 0, 23200
IAST [candidate] (22.389 ms) : 0, 22389
AppSec [baseline] (56.086 ms) : 0, 56086
AppSec [candidate] (57.119 ms) : 0, 57119
Remote Config [baseline] (625.176 µs) : 0, 625
Remote Config [candidate] (621.649 µs) : 0, 622
Telemetry [baseline] (8.725 ms) : 0, 8725
Telemetry [candidate] (8.641 ms) : 0, 8641
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.038 s) : 0, 1037811
Total [baseline] (10.45 s) : 0, 10450042
Agent [candidate] (1.037 s) : 0, 1036923
Total [candidate] (10.517 s) : 0, 10516810
section appsec
Agent [baseline] (1.188 s) : 0, 1187738
Total [baseline] (10.753 s) : 0, 10752954
Agent [candidate] (1.187 s) : 0, 1187006
Total [candidate] (10.814 s) : 0, 10814346
section iast
Agent [baseline] (1.169 s) : 0, 1169278
Total [baseline] (10.971 s) : 0, 10971280
Agent [candidate] (1.175 s) : 0, 1175039
Total [candidate] (11.058 s) : 0, 11057641
section profiling
Agent [baseline] (1.26 s) : 0, 1259918
Total [baseline] (10.837 s) : 0, 10836722
Agent [candidate] (1.26 s) : 0, 1260427
Total [candidate] (10.895 s) : 0, 10894971
gantt
title petclinic - break down per module: candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (715.637 ms) : 0, 715637
BytebuddyAgent [candidate] (715.036 ms) : 0, 715036
GlobalTracer [baseline] (239.215 ms) : 0, 239215
GlobalTracer [candidate] (238.37 ms) : 0, 238370
AppSec [baseline] (55.255 ms) : 0, 55255
AppSec [candidate] (55.119 ms) : 0, 55119
Remote Config [baseline] (681.338 µs) : 0, 681
Remote Config [candidate] (689.155 µs) : 0, 689
Telemetry [baseline] (12.095 ms) : 0, 12095
Telemetry [candidate] (12.827 ms) : 0, 12827
section appsec
BytebuddyAgent [baseline] (738.547 ms) : 0, 738547
BytebuddyAgent [candidate] (737.793 ms) : 0, 737793
GlobalTracer [baseline] (237.263 ms) : 0, 237263
GlobalTracer [candidate] (237.131 ms) : 0, 237131
AppSec [baseline] (177.067 ms) : 0, 177067
AppSec [candidate] (177.301 ms) : 0, 177301
Remote Config [baseline] (665.075 µs) : 0, 665
Remote Config [candidate] (659.953 µs) : 0, 660
Telemetry [baseline] (8.384 ms) : 0, 8384
Telemetry [candidate] (8.324 ms) : 0, 8324
IAST [baseline] (21.676 ms) : 0, 21676
IAST [candidate] (21.603 ms) : 0, 21603
section iast
BytebuddyAgent [baseline] (836.02 ms) : 0, 836020
BytebuddyAgent [candidate] (840.709 ms) : 0, 840709
GlobalTracer [baseline] (229.894 ms) : 0, 229894
GlobalTracer [candidate] (230.723 ms) : 0, 230723
AppSec [baseline] (56.444 ms) : 0, 56444
AppSec [candidate] (56.523 ms) : 0, 56523
Remote Config [baseline] (606.128 µs) : 0, 606
Remote Config [candidate] (609.781 µs) : 0, 610
Telemetry [baseline] (8.616 ms) : 0, 8616
Telemetry [candidate] (8.704 ms) : 0, 8704
IAST [baseline] (22.696 ms) : 0, 22696
IAST [candidate] (22.733 ms) : 0, 22733
section profiling
ProfilingAgent [baseline] (96.09 ms) : 0, 96090
ProfilingAgent [candidate] (95.508 ms) : 0, 95508
BytebuddyAgent [baseline] (709.714 ms) : 0, 709714
BytebuddyAgent [candidate] (712.126 ms) : 0, 712126
GlobalTracer [baseline] (348.874 ms) : 0, 348874
GlobalTracer [candidate] (348.793 ms) : 0, 348793
AppSec [baseline] (55.211 ms) : 0, 55211
AppSec [candidate] (53.935 ms) : 0, 53935
Remote Config [baseline] (693.652 µs) : 0, 694
Remote Config [candidate] (678.317 µs) : 0, 678
Telemetry [baseline] (8.958 ms) : 0, 8958
Telemetry [candidate] (8.861 ms) : 0, 8861
Profiling [baseline] (96.114 ms) : 0, 96114
Profiling [candidate] (95.533 ms) : 0, 95533
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 13 metrics, 17 unstable metrics. Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section baseline
no_agent (1.354 ms) : 1333, 1374
. : milestone, 1354,
appsec (1.721 ms) : 1697, 1745
. : milestone, 1721,
appsec_no_iast (1.743 ms) : 1719, 1768
. : milestone, 1743,
code_origins (1.701 ms) : 1669, 1734
. : milestone, 1701,
iast (1.517 ms) : 1493, 1542
. : milestone, 1517,
profiling (1.509 ms) : 1485, 1532
. : milestone, 1509,
tracing (1.497 ms) : 1472, 1522
. : milestone, 1497,
section candidate
no_agent (1.346 ms) : 1327, 1366
. : milestone, 1346,
appsec (1.734 ms) : 1710, 1758
. : milestone, 1734,
appsec_no_iast (1.716 ms) : 1691, 1741
. : milestone, 1716,
code_origins (1.676 ms) : 1641, 1710
. : milestone, 1676,
iast (1.509 ms) : 1485, 1533
. : milestone, 1509,
profiling (1.547 ms) : 1523, 1571
. : milestone, 1547,
tracing (1.498 ms) : 1475, 1522
. : milestone, 1498,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section baseline
no_agent (387.436 µs) : 368, 407
. : milestone, 387,
iast (514.994 µs) : 493, 537
. : milestone, 515,
iast_FULL (731.879 µs) : 710, 754
. : milestone, 732,
iast_GLOBAL (566.076 µs) : 543, 589
. : milestone, 566,
iast_HARDCODED_SECRET_DISABLED (512.677 µs) : 490, 535
. : milestone, 513,
iast_INACTIVE (464.016 µs) : 442, 486
. : milestone, 464,
iast_TELEMETRY_OFF (501.016 µs) : 478, 524
. : milestone, 501,
tracing (459.293 µs) : 438, 481
. : milestone, 459,
section candidate
no_agent (382.845 µs) : 363, 403
. : milestone, 383,
iast (514.353 µs) : 492, 537
. : milestone, 514,
iast_FULL (732.584 µs) : 711, 754
. : milestone, 733,
iast_GLOBAL (553.605 µs) : 532, 575
. : milestone, 554,
iast_HARDCODED_SECRET_DISABLED (510.793 µs) : 489, 532
. : milestone, 511,
iast_INACTIVE (464.066 µs) : 442, 486
. : milestone, 464,
iast_TELEMETRY_OFF (500.362 µs) : 477, 523
. : milestone, 500,
tracing (458.104 µs) : 437, 479
. : milestone, 458,
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.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section baseline
no_agent (1.48 ms) : 1469, 1491
. : milestone, 1480,
appsec (2.348 ms) : 2305, 2391
. : milestone, 2348,
iast (2.129 ms) : 2074, 2184
. : milestone, 2129,
iast_GLOBAL (2.173 ms) : 2118, 2229
. : milestone, 2173,
profiling (1.997 ms) : 1952, 2041
. : milestone, 1997,
tracing (1.953 ms) : 1911, 1995
. : milestone, 1953,
section candidate
no_agent (1.479 ms) : 1468, 1491
. : milestone, 1479,
appsec (2.345 ms) : 2302, 2388
. : milestone, 2345,
iast (2.125 ms) : 2070, 2180
. : milestone, 2125,
iast_GLOBAL (2.168 ms) : 2112, 2223
. : milestone, 2168,
profiling (1.975 ms) : 1932, 2018
. : milestone, 1975,
tracing (1.948 ms) : 1906, 1990
. : milestone, 1948,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.48.0-SNAPSHOT~a0b2edd0d0, baseline=1.48.0-SNAPSHOT~71cbb065b9
dateFormat X
axisFormat %s
section baseline
no_agent (15.459 s) : 15459000, 15459000
. : milestone, 15459000,
appsec (14.983 s) : 14983000, 14983000
. : milestone, 14983000,
iast (19.147 s) : 19147000, 19147000
. : milestone, 19147000,
iast_GLOBAL (18.128 s) : 18128000, 18128000
. : milestone, 18128000,
profiling (15.695 s) : 15695000, 15695000
. : milestone, 15695000,
tracing (15.033 s) : 15033000, 15033000
. : milestone, 15033000,
section candidate
no_agent (15.423 s) : 15423000, 15423000
. : milestone, 15423000,
appsec (14.759 s) : 14759000, 14759000
. : milestone, 14759000,
iast (18.972 s) : 18972000, 18972000
. : milestone, 18972000,
iast_GLOBAL (18.43 s) : 18430000, 18430000
. : milestone, 18430000,
profiling (15.677 s) : 15677000, 15677000
. : milestone, 15677000,
tracing (14.716 s) : 14716000, 14716000
. : milestone, 14716000,
|
@@ -31,7 +31,7 @@ public void methodAdvice(MethodTransformer transformer) { | |||
|
|||
@Override | |||
public String[] helperClassNames() { | |||
return new String[] {packageName + ".S3Interceptor", packageName + ".TextMapInjectAdapter"}; |
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 file TextMapInjectAdapter
was never used
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
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.
Looks reasonable to me, but someone from IDM should also take a look
(also rebase on top of latest master to pick up fixes for the failing CI tests below)
return value.n(); | ||
} else if (value.b() != null) { | ||
// For binary values, convert the bytes back to string | ||
return new String(value.b().asByteArray(), java.nio.charset.Charset.defaultCharset()); |
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.
are we sure about the charset?
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.
Yes, from manual testing, this works the same as the dd-trace-js implementation
https://github.com/DataDog/dd-trace-js/blob/1ce996b79839d1a7e77b9831850b85d38e94417a/packages/datadog-plugin-aws-sdk/src/util.js#L43-L44
def links = new JsonSlurper().parseText(spanLinks) | ||
assert links.size() == 1 | ||
def link = links[0] | ||
assert link["attributes"] != null |
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.
Very soon we'll have a link
assertion that will allow asserting links on a span. I will migrate that test
static final String S3_PTR_KIND = "aws.s3.object"; | ||
static final String LINK_KIND = "span-pointer"; | ||
|
||
@Override | ||
public Map<String, Object> processTags( | ||
Map<String, Object> unsafeTags, DDSpanContext spanContext, List<AgentSpanLink> spanLinks) { | ||
AgentSpanLink s3Link = handleS3SpanPointer(unsafeTags); |
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.
As soon as we'll have more span pointer sources we'll need to think about refactoring this class for a better mechanism. But it's not for this PR
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.
looks ok. I left one question about the charset when converting bytes to string
What Does This Do
Creates an instrumentation for DynamoDb and adds span pointers in DynamoDb for
updateItem
anddeleteItem
requests.These two are the simplest cases, since we know the primary key/values. In a future PR, I will get to
putItem
and batch updates, since those are more complicated cases.Span pointers are similar to Span Links, but for cases when it is impossible to pass the Trace ID and Span ID between the spans that need to be linked.
When the calculated hashes for the upstream and downstream lambdas match, the Datadog frontend will link the two traces together.

When clicking on the linked span, a new tab opens linking to the downstream Lambda function that was triggered by this DynamoDB item update.
This feature can be disabled by setting the config
trace.aws.add.span.pointers
or Lambda environment variableDD_TRACE_AWS_ADD_SPAN_POINTERS
to false.Motivation
Span pointers is a new feature being developed by the Serverless team. This feature already exists in Python & Node, and I'm working on adding it to other runtimes (.NET, Java, Golang).
Additional Notes
I also added tests:
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]