Skip to content

[Example] Trace correlation between microservices using context #2281

Answered by Aneurysm9
etiennejournet asked this question in Q&A
Discussion options

You must be logged in to vote

For this to work you need the propagation API and an implementation of a Propagator to be used by the HTTP client and server at each end. The stdlib HTTP client doesn't serialize and ship a context.Context when you create a NewRequestWithContext(), it only makes it available to the http.Client and its associated RoundTripper. We provide the otelhttp.Transport and otelhttp.Handler types to assist with propagating trace context across HTTP requests. Its example is hopefully helpful, but your implementation requires very little change to incorporate them.

        tracer := otel.Tracer("hello-world-frontend")

        // Register a propagator
        otel.SetTextMapPropagator(propagation.Trac…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@etiennejournet
Comment options

Answer selected by etiennejournet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #2278 on October 07, 2021 14:03.