Skip to content

How to add distributed tracing support to SqsTemplate #902

Answered by jkuipers
jkuipers asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this seems to do the trick (Tracing is a brave.Tracing type):

    @Bean
    SqsTemplate sqsTemplate(SqsAsyncClient sqsAsyncClient, ObjectMapper objectMapper, Tracing tracing) {
        var injector = tracing.propagation().injector(
                (Propagation.Setter<Map<String, Object>, String>) (headersMap, key, value) -> {
                    // only propagate the traceparent attr, no additional baggage, since SQS only supports a max of 10 attrs
                    if (key.startsWith("trace")) headersMap.put(key, value);
                });
        var converter = new SqsMessagingMessageConverter() {
            @Override
            public Message fromMessagingMessage(o…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@jkuipers
Comment options

@jkuipers
Comment options

Answer selected by jkuipers
@jkuipers
Comment options

@tomazfernandes
Comment options

@jkuipers
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants