Merged
Conversation
f17702a to
efa7bc3
Compare
duncanista
approved these changes
Dec 18, 2024
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\/([^\/]*)/); |
Contributor
There was a problem hiding this comment.
should we be more defensive in this regex? or do we assume that this will always be an arn in this particular format?
Contributor
Author
There was a problem hiding this comment.
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; |
Contributor
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andbatchWriteItemsrequests.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
{ "shouldUseV2": false, "twoKeyTable": false, "shouldPutItem": false, "shouldUpdateItem": false, "shouldDeleteItem": false, "shouldBatchWriteItems": false, "shouldTransactWriteItems": false }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