-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add DynamoDB Downstream Span Pointers #600
Conversation
f17702a
to
efa7bc3
Compare
93b7c32
to
2e9c05c
Compare
c279f26
to
55aa3c0
Compare
|
||
function getTableNameFromARN(arn: string): string | undefined { | ||
// ARN format: arn:aws:dynamodb:<region>:<account-id>:table/<table-name>/stream/<YYYY-MM-DDThh:mm:ss.ms> | ||
const match = arn.match(/table\/([^\/]*)/); |
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.
should we be more defensive in this regex? or do we assume that this will always be an arn in this particular format?
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.
Hmm, i don't see how the arn could be of a different format unless aws releases a breaking change. we should keep this in mind though and fix in the future if needed
|
||
const keys = record.dynamodb?.Keys; | ||
const eventSourceARN = record.eventSourceARN; | ||
const tableName = record.eventSourceARN ? getTableNameFromARN(eventSourceARN) : undefined; |
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.
out of curiosity: why not say const tableName = eventSourceARN ? ...
here since we've already pulled the eventSourceARN
out of the record
in the line above?
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 point, will fix in #607
What does this PR do?
Adds span pointers to spans for Lambdas triggered by DynamoDB INSERT, MODIFY, and REMOVE event streams. In practice, this covers DynamoDB updates caused by
putItem
,updateItem
,deleteItem
,transactWriteItems
, andbatchWriteItems
requests.This also updates the span pointer util imports that were modified in DataDog/dd-trace-js#4912.
Motivation
This feature already exists in Python, and I'm working on adding it to all other runtimes (Node, .NET, Java, Golang).
Testing Guidelines
Easy: Checkout this span enable the feature flag, and you will see that it's pointing to the downstream Lambda.
More thorough: Run this Lambda function with the event payload
As you can see, there are a lot of different cases to test -- v2 vs v3 AWS SDK, one primary key vs two primary key tables, and the 5 different types of requests. You can test by enabling one of the requests, running the Lambda, and then check Datadog to ensure that the spans are properly linked.
Additional Notes
Types of Changes
Check all that apply