-
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 S3 Downstream Span Pointers #587
base: main
Are you sure you want to change the base?
Conversation
src/utils/span-pointers.ts
Outdated
* @param {any} event - The event object containing source-specific data. | ||
* @returns {SpanPointerAttributes[] | undefined} An array of span pointer attribute objects, or undefined if none could be computed. | ||
*/ | ||
export function getSpanPointerAttributes(eventSource: eventTypes | undefined, event: any): SpanPointerAttributes[] | 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.
} | ||
} | ||
|
||
function processS3Event(event: any): SpanPointerAttributes[] { |
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.
@@ -323,9 +323,8 @@ function extractHTTPTags(event: APIGatewayEvent | APIGatewayProxyEventV2 | ALBEv | |||
/** | |||
* extractTriggerTags parses the trigger event object for tags to be added to the span metadata | |||
*/ | |||
export function extractTriggerTags(event: any, context: Context) { | |||
export function extractTriggerTags(event: any, context: Context, eventSource: eventTypes | 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.
d0a666e
to
c8aa5a8
Compare
*/ | ||
export function getSpanPointerAttributes( | ||
eventSource: eventTypes | undefined, | ||
event: any, |
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.
c8aa5a8
to
a3b587b
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.
the span pointer stuff looks fine, though some aspects of the api are a little strange. we may want someone with more js experience to take a look as well.
|
||
for (const record of records) { | ||
const eventName = record.eventName; | ||
if (!["ObjectCreated:Put", "ObjectCreated:Copy", "ObjectCreated:CompleteMultipartUpload"].includes(eventName)) { |
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 restrict us to only these particular object created types instead of ObjectCreated:*
?
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.
We only support creating span pointers for these three operations on the upstream case. I guess it doesn't hurt to create span pointers downstream in other cases; we could change the check to
if (!eventName.startsWith("ObjectCreated"))
src/utils/span-pointers.ts
Outdated
eventSource: eventTypes | undefined, | ||
event: any, | ||
): SpanPointerAttributes[] | undefined { | ||
console.log('[LIBRARY] getSpanPointerAttributes(): ', eventSource) |
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.
src/trace/listener.ts
Outdated
this.stepFunctionContext = StepFunctionContextService.instance().context; | ||
|
||
console.log('[LIBRARY] Getting span pointer attributes') |
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.
src/trace/listener.ts
Outdated
|
||
if (this.wrappedCurrentSpan) { | ||
for (const attributes of this.spanPointerAttributesList) { | ||
console.log('[LIBRARY] Adding attributes:', attributes) |
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.
src/trace/listener.ts
Outdated
|
||
console.log('[LIBRARY] Getting span pointer attributes') | ||
const result = getSpanPointerAttributes(eventSource, event); | ||
console.log('[LIBRARY] result:', result) |
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.
c9e623b
to
ea5594b
Compare
What does this PR do?
Tests will fail until my changes in DataDog/dd-trace-js#4875 are out.
Adds span pointers to spans for Lambdas triggered by
putObject
,copyObject
, andcompleteMultipartUpload
events.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 backend will automatically 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 S3 object update.Motivation
This feature already exists in Python, and I'm working on adding it to all other runtimes (Node, .NET, Java, Golang).
Testing Guidelines
Run this Lambda function with the event payload
and change one of the bools to true. Also, try both with AWS SDK v2 and v3. Enable the span pointers feature flag, and check Datadog to ensure that the spans are properly linked.
Additional Notes
Types of Changes
Check all that apply