Return traceId in header response.
See original GitHub issueDescription To debug more easily an Ajax request I propose to return the traceId in response header.
Implementation ideas
I’ve follow this code https://github.com/quarkusio/quarkus/blob/master/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/MDCScope.java
package com.damdamdeo.todo.publicfrontend.interfaces;
import io.jaegertracing.internal.JaegerSpanContext;
import io.opentracing.SpanContext;
import io.opentracing.Tracer;
import javax.inject.Inject;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
@Provider
public class TraceIdResponseInjector implements ContainerResponseFilter {
@Inject
Tracer tracer;
private static final String TRACE_ID = "traceId";
@Override
public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext responseContext) throws IOException {
final SpanContext spanContext = tracer.scopeManager().active().span().context();
if (spanContext instanceof JaegerSpanContext) {
responseContext.getHeaders().add(TRACE_ID, ((JaegerSpanContext) spanContext).getTraceId());
}
}
}
I guess it should be implemented in quarkus-smallrye-opentracing
.
Regards,
Damien
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Adding the traceId from Spring Cloud Sleuth to response
Using this method: MDC.get("traceId") will return a string with the value, and can do whatever you want with it. About putting that information...
Read more >9. Customizations - Spring Cloud
In the following example we will register the TraceFilter bean and we will add the ZIPKIN-TRACE-ID response header containing the current Span's trace...
Read more >HTTP header manipulation - Envoy Proxy
The trace ID, parent ID and sampling decision are added to HTTP requests in the tracing header. See more on AWS X-Ray tracing...
Read more >OpenTelemetry Traceparent HTTP Header [Go] - Uptrace
Using the header, you can extract a trace id to find the trace in a distributed tracing tool open in new window, for...
Read more >Transaction and Trace IDs - Pages - Support
If you sent a trace ID, a traceID object with that value is also returned in the wrapper object of the response. If...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this makes sense, though there probably should be a configuration switch to turn it off. (I think it’s pretty safe to have it on by default, even in production, but some users in highly regulated environments would probably like to turn it off.)
CC @pavolloffay
Yes similar to Spring Boot it should respect incoming HTTP headers for Trace/Span and always put them on the outgoing response. This way you can trace microservice to microservice calls across your organization. This is similar to what Spring Boot Slueth does.