Skip to content
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

Change span injection/extraction from HTTP request #821

Merged
merged 1 commit into from
Jan 9, 2019
Merged

Change span injection/extraction from HTTP request #821

merged 1 commit into from
Jan 9, 2019

Conversation

nboukeffa
Copy link
Contributor

Today, TextMap format is used when injecting or extracing span from HTTP requests.

This format will treat the HTTP header value (that contains the span) as is (without decoding). Conversely the HTTPHeaders format will try to URL decode the value first.

The issue is that some opentracing clients like java jaeger client is URL encoding the HTTP header value before sending it over the wire. Then when the server receive the request and try to extract the span from it it will fail if TextMap format is used istead HTTPHeaders format.

For example the java jaeger client will send something like this: Uber-Trace-Id: 9ec076efd89825a%3A9c876c01059545b2%3Ab9ec076efd89825a%3A1 but the golang jaeger client is expecting this Uber-Trace-Id: 9ec076efd89825a:9c876c01059545b2:b9ec076efd89825a:1 when the TextMap format is used.

In this case the call results to the following error: String does not match tracer state format

Because the http.go file is used precisely for dealing with span in a HTTP context, I propose to default the span format to HTTPHeaders

Today, `TextMap` format is used when injecting or extracing *span* from HTTP requests.

This format will treat the HTTP header value (that contains the span) as is (without decoding). Conversely the `HTTPHeaders` format will try to URL decode the value first.

The issue is that some opentracing clients like [java jaeger client](https://github.com/jaegertracing/jaeger-client-java/blob/f5f6ad1f4eaf606aba07562b7543958ec4658ebe/jaeger-core/src/main/java/io/jaegertracing/internal/propagation/TextMapCodec.java#L206) is URL encoding the HTTP header value before sending it over the wire. Then when the server receive the request and try to extract the span from it it will fail if `TextMap` format is used istead `HTTPHeaders` format.

For example the java jaeger client will send something like this: `Uber-Trace-Id: 9ec076efd89825a%3A9c876c01059545b2%3Ab9ec076efd89825a%3A1` but the golang jaeger client is expecting this `Uber-Trace-Id: 9ec076efd89825a:9c876c01059545b2:b9ec076efd89825a:1` when the `TextMap` format is used.

In this case the call results to the following [error](https://github.com/jaegertracing/jaeger-client-go/blob/master/context.go#L111): `String does not match tracer state format`

Because the `http.go` file is used precisely for dealing with span in a HTTP context, I propose to default the span format to `HTTPHeaders`
@basvanbeek
Copy link
Member

Thanks for the PR. Looks good to me so merging.

@basvanbeek basvanbeek merged commit 1e404df into go-kit:master Jan 9, 2019
@nboukeffa nboukeffa deleted the jaeger-span-default-format branch January 9, 2019 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants