Skip to content

[instrumentation-amqplib] possible bug with baggage propagation while using span links on consume #2772

Open
@slittle-tn

Description

@slittle-tn

What version of OpenTelemetry are you using?

  • api 1.9.0
  • sdk-node 0.57.0
  • instrumentation-amqplib 0.46.0

What version of Node are you using?

23.9.0

What did you do?

I can't share the actual code, but the gist is this:

  • Configured the AMQP instrumentation with useLinksForConsume: true
  • Added a value to the Baggage (in a non-Node service)
  • When consuming the message (in Node), attempted to log the baggage value

What did you expect to see?

The value added to the baggage

What did you see instead?

The value was undefined

Additional context

This all hinges on if the baggage should still propagate even if we're in a new trace, which I believe is true, but if not then this isn't a bug.

I confirmed in the RabbitMQ console that the baggage header was there as expected prior to consuming, so it's not about the non-Node implementation.
The issue goes away without useLinksForConsume: true

I looked at the code a bit (getConsumePatch()), and I think the issue is that when span links are enabled the full parent context is set to undefined in order to start a new trace, but that context includes both the span context and the baggage. I'm not sure how all of it works, but I was able to get the baggage to propagate as expected by

  1. Removing the parentContext = undefined line
  2. Adding root: true to the options in the call to tracer.startSpan()

Basically trying to reset the span context without losing anything else in the context. That may not be the correct/complete solution though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds:specThis cannot be implemented without some changes or clarifications in the specification or semconv

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions