0

I just follow this tutorial here https://quarkus.io/guides/opentelemetry to create a quarkus application with openTelemetry and jaeger.

It works fine, I can see all my requests in jaeger, but there is no response body.

My problem here is that I have several microservices communication with each other and sometimes one gets an error that stops the whole process, so I have to debbug one by one to find which service did fail. If I get this response body in jaeger this would be easily to identify which service trigger any exception.

So right now I don't have any response body in my jaeger and I don't know if jaeger doesn't show any response and I have to find another tool, or if there is some configuration I need to do in my opentelemetry to send it to jaeger.

Can someone help? There is any way to see http responses with openTelemetry?

Gilson
  • 478
  • 7
  • 14
  • Errors should show up automatically without any additional configuration. Can you please open an issue with a reproducer here: https://github.com/quarkusio/quarkus/issues? – Roberto Cortez Sep 05 '22 at 12:52

3 Answers3

0

Assuming you are making HTTP requests, on Quarkus, HTTP request spans will show the operation result: HTTP Span details pic.. If you need to add specific details about the response you might need to create a manual span for it.

Bruno Baptista
  • 209
  • 1
  • 6
0

My solution was to add it manually as attribute of current span:

final Span span = io.opentelemetry.api.trace.Span.current();
span.setAttribute("http.response.headers", header);
span.setAttribute("http.response.body", body);
if (httpStatus >= Response.Status.BAD_REQUEST.getStatusCode()) {
     span.setStatus(StatusCode.ERROR);
}

I still thinking that quarkus-opentelemetry should have an application property to define that we want header and/or body for request, response, client request and client response on Span.

Gilson
  • 478
  • 7
  • 14
0

I solved this problem using Quarkus ContainerRequestFilter to intercept all requests and Span bean provided by quarkus-opentelemetry

So my solution looked like this:

import io.opentelemetry.api.trace.Span;

import javax.inject.Inject;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;

@Provider
@JBossLog
public class OtelCustomInterceptor implements ContainerRequestFilter {
    
    @Inject
    Span span;

    @Override
    public void filter(ContainerRequestContext context) {
        var headers = context.getHeaders();
        headers.forEach((k, l) -> l.forEach(
            header -> setSpan(k, header, span)
        ));
    }

    private static Span setSpan(String k, String header, Span span) {
        return span.setAttribute("http.request.headers.%s".formatted(k), header);
    }

}