Skip to content

chore(messenger): add trace parent in dispatched messages (AMQP) #171

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

Conversation

jvocampings
Copy link

@jvocampings jvocampings commented Apr 16, 2025

Hello,

I'd like to submit to you that PR.

Handling propagation of trace in AMQP context by adding custom stamp to dispatched messages. The stamp contains the trace parent normalized by OpenTelemetry. It does not read the stamp from incoming message (must be done in another PR or in this one if you prefer).

An exemple with a message dispatched to RabbitMQ:

X-Message-Stamp-FriendsOfOpenTelemetry\OpenTelemetryBundle\Instrumentation\Symfony\Messenger\TraceStamp: [{"traceParent":"00-57cdad60c0711de6da2ab8814fc91e36-c6bb8daefdd291b0-01"}]

Add the middleware open_telemetry.instrumentation.messenger.propagation.amqp.middleware to your bus to activate it. e.g.

buses:
    messenger.bus.default:
        middleware:
            - open_telemetry.instrumentation.messenger.propagation.amqp.middleware

I prefer writing tests once modifications are OK for you. But I can add them asap if you prefer.

@jvocampings jvocampings requested a review from a team as a code owner April 16, 2025 15:30
@jvocampings jvocampings changed the title chore(messenger): add trace parent in dispatched messages (AMQP)) chore(messenger): add trace parent in dispatched messages (AMQP) Apr 16, 2025
@jvocampings jvocampings force-pushed the messenger-propagation branch from ac70917 to cb84fec Compare April 16, 2025 15:31
Copy link
Contributor

@gaelreyrol gaelreyrol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your involvement on this bundle, I really appreciate it!

First, I think this can fully generic. I mean, why restricting this to AMQP as long as the stamp is serializable.

On the propagation aspect, I need to do some research to make sure I fully master this part before implementing it otherwise I will not be able to provide support and extend it.

Are you in a hurry to get this working? I am not sure I will be able to work on this until this week-end.

@jvocampings
Copy link
Author

First, I think this can fully generic. I mean, why restricting this to AMQP as long as the stamp is serializable.

In a Messenger middleware, I know I can check if the message is dispatched if it has the AmqpStamp. I don't know any generic way to check that.

Are you in a hurry to get this working? I am not sure I will be able to work on this until this week-end.

I'm not in a hurry. Thank you :)
I know the ecosystem is still young so don't worry.

@gaelreyrol
Copy link
Contributor

In a Messenger middleware, I know I can check if the message is dispatched if it has the AmqpStamp. I don't know any generic way to check that.

You can check if a TraceableStamp has already been applied or not, without considering if it has been dispatched.

I'm not in a hurry. Thank you :) I know the ecosystem is still young so don't worry.

Thanks! I'll do my best to come to you as soon as I covered the subject in my mind 😅 .

@gaelreyrol
Copy link
Contributor

Hi @jvocampings, I think this PR should be merged with #173 to facilitate the instrumentation of the messenger component.

@jvocampings
Copy link
Author

Hi @jvocampings, I think this PR should be merged with #173 to facilitate the instrumentation of the messenger component.

yes done: #173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants