-
Notifications
You must be signed in to change notification settings - Fork 227
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
feat: add observability for lambda-to-lambda invocations #3623
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -705,6 +705,14 @@ function elasticApmAwsLambda(agent) { | |
// Look for trace-context info in headers or messageAttributes. | ||
let traceparent; | ||
let tracestate; | ||
if ( | ||
triggerType === TRIGGER_GENERIC && | ||
event.traceparent && | ||
event.tracestate | ||
) { | ||
traceparent = event.traceparent; | ||
tracestate = event.tracestate; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fdaciuk Thanks for the PR. Can you show some simple Lambda function code that uses this? That would help me understand a bit better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @trentm. Exactly! I don't know if there is better way to do this, but that update worked for my use case. I'm invoking the lambda like this: const command = new InvokeCommand({
FunctionName: "my-lambda",
InvocationType: "RequestResponse",
Payload: new TextEncoder().encode(JSON.stringify({ traceparent, tracestate })),
}) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't a current way to do this ... except possibly Amazon's X-Ray support might enable making the connection. We aren't currently doing anything with X-Ray in our Lambda support. Providing some way for this manual distributed tracing in Lambda is interesting. I like the idea. I wonder about instead using I'm not sure if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a good question. I'm not sure, but love the idea that this might be automatic. We're creating a library on our company to abstract the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a heads up that I won't be able to get to this soon. :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No problem. For now, we're using a forked version of this repo with these updates. I hope it's not a problem until you decide whether or not it's a valuable feature in this lib =) |
||
if ( | ||
(triggerType === TRIGGER_API_GATEWAY || triggerType === TRIGGER_ELB) && | ||
event.headers | ||
|
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.
Was this change to avoid the extra span necessary for the Service Map connection to work? Or was this just to avoid having an addition span in the trace waterfall?
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.
Both I guess. If this span is created when a lambda is invoked, I can see two entries on Service Map: one empty (created by this span) and other with the full tracing (created from the code send in
lib/lambda.js
.This code just removes the empty one.