-
Notifications
You must be signed in to change notification settings - Fork 538
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: implement lambda context parenting #431
Conversation
Without this, spans created in the lambda function are not part of the same trace as the handler span.
…trib into lambda_context
Codecov Report
@@ Coverage Diff @@
## main #431 +/- ##
==========================================
+ Coverage 95.26% 95.29% +0.03%
==========================================
Files 140 140
Lines 8399 8519 +120
Branches 815 824 +9
==========================================
+ Hits 8001 8118 +117
- Misses 398 401 +3
|
Using the propagator directly in instrumentations is typically not the recommended approach. You should use |
@dyladan Yeah the spec specifically says to use the X-Ray propagator This is because the X-Ray propagator (better name would be AWS trace format) is an implementation detail of AWS right now. Eventually we'll support more formats but until then, it's the only format that Lambda supports. So if you imagine a user that has their entire stack set to W3C, they could have
AWS instrumentation (call to S3) must use the x-amzn header, regardless of what the user set, or propagation will be lost. Similarly, while we could expect the Lambda function to define w3c and x-amzn as a composite propagator, it's wasteful and unintuitive - there's no need to send x-amzn to C, we only want it to parse the environment variable set by Lambda. So, until AWS supports more formats (a while away), forcing the propagator is the best user experience on AWS. I realized the note I added for SQS would be helpful for the parenting section too The key point is the format is not directly related to X-Ray and is the correct format for non-X-Ray users too, any AWS user must be using the X-Amzn-Trace-Id header to get propagation within the cloud. |
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.
Generally LGTM
Context as OtelContext, | ||
context as otelContext, |
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 the two different context
s here?
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.
There's context
, an object with methods exposing the context API of type ContextAPI
. Then there's Context
, which is the type of an actual passed around context. It would be nice I think if context
could be renamed contextAPI
or similar.
…trib into lambda_parent
Thanks - rebased |
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.
lgtm, just 2 nit picks
kind: SpanKind.SERVER, | ||
attributes: { | ||
[SemanticAttributes.FAAS_EXECUTION]: context.awsRequestId, | ||
'faas.id': context.invokedFunctionArn, |
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.
Nit: 'faas.id' - if there isn't a semantic attributes maybe create some const for that ?
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.
plugins/node/opentelemetry-instrumentation-aws-lambda/src/aws-lambda.ts
Outdated
Show resolved
Hide resolved
…trib into lambda_parent
…contrib into lambda_parent
So sorry for the huge delay on this, updated |
…trib into lambda_parent
Merged master to fix build. Think this is good for another look |
Which problem is this PR solving?
Short description of the changes
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/instrumentation/aws-lambda.md#determining-the-parent-of-a-span
Note, this contains #424, happy to rebase this after that's merged