Parent traceID not propogating to REST calls using otelgin.Middleware
HI
Trying sample Application using Gin and otelgin.Middleware() to stich chain of REST API calls. Below is the scenario tried.
- Make rest call to Books Application
- Books applications make call to Stores Applications to get all books from All stores
- Store applications just return empty.
Actually Books API call and Store Api calls' should be linked. But it not happening and both calls having different TraceID.
Note : Same tried with Mux it is working. Signoz used for view traces
Screenshots:
Books Application:
Store Application:
Example code available in https://github.com/Connect2naga/Examples/tree/main/Standalone
Please correct me if any thing missed or need to change the confirguration.
is it really a config issue or Bug, could you please confirm?
You're making outgoing requests with the default net/http client. https://github.com/Connect2naga/Examples/blob/main/Standalone/book/main.go#L102
You need to use the otelhttp one (or at least its transport), or outgoing HTTP requests won't include the trace ID and can't be propagated. https://github.com/open-telemetry/opentelemetry-go-contrib/blob/main/instrumentation/net/http/otelhttp/client.go#L28
ok, Shouldn't be the same case in mux as well. for mux i am able to create propagate the traceID, let me check above configuration.
Any news about this? Are there any workarounds?
@rasert this issue appeared to have been a configuration problem. You need to use the otelhttp client for outgoing requests. This isn't a bug, and the workaround is to use the library as documented.
https://github.com/open-telemetry/opentelemetry-go-contrib/blob/7ce8deb5b42cccf5237d848b99469dca0ef519c9/instrumentation/net/http/otelhttp/client.go#L17