Closed ImDevinC closed 1 year ago
@willarmiros can you look at this since you're the component owner? I think this is more of a feature request to support trace headers in sqs message attributes than it is a bug.
Thanks @dyladan. I filed as a bug because a trace header is already added to sqs message attributes automatically, but maybe I'm misunderstanding it's purpose
Added by the sqs instrumentation or by sqs itself? I think the messaging group typically recomends using links instead of parent span
I'm 99% sure it's the sqs instrumentation adding the context, as I'm not specifying any message attributes when I build the message in producer.ts
const req: SQS.SendMessageRequest = {
QueueUrl: process.env.SQS_URL!,
MessageBody: body,
};
return new Promise<number>((resolve, reject) => {
const resp = sqs.sendMessage(req, (res) => {
resolve(res?.statusCode ?? 0);
});
I think the messaging group typically recommends using links instead of parent span
This is correct, since it is possible for several SQS messages to be batched into a single invocation of a Lambda function, the correct behavior per the spec is to start a new trace in the Lambda function (or use the Lambda's X-Ray trace context since it is always a new trace) and link it to all upstream SQS Message trace(s).
I'm 99% sure it's the sqs instrumentation adding the context
I believe both the Lambda AND SQS instrumentations need to be updated to comply with this behavior. Lambda is a special case because the handler is provided the SQS Messages directly in its payload, whereas other applications that are pulling from SQS directly use the SQS client. So both the Lambda handler and SQS Client are possible entry points for this instrumentation.
FWIW, we are planning on implementing this behavior in the coming months.
Thanks, the linking is what I was missing. Appreciate all the insight, and glad to hear that autoinstrumentation of this is on the roadmap. I'll close this since you solved my issue
What version of OpenTelemetry are you using?
What version of Node are you using?
16
What did you do?
I'm running two lambdas in AWS that communicate through an SQS queue. Both lambdas are invoked with
NODE_OPTIONS: --require tracing.js
to use the same tracing instrumentation that loads ahead of the actual lambda code. Both functions properly create their own unique traces, and the SQS message that gets published does have aMessageAttribute
oftraceparent=<traceid>
. However the consumer lambda (consumer.ts
) does not pick up this traceparent when initializing and therefore doesn't attribute the trace properly to the producer.tracing.ts
producer.ts
consumer.ts
What did you expect to see?
I would expect to see both the consumer and parent trace properly linked together.
What did you see instead?
This produces two distinct traces that are not linked together.