5

We are re-building our software platform using a microservice architecture approach.

Most of it using Spring Boot libraries, and for our entry points we are using Spring Cloud Gateway which can be easily integrated with Jaeger to have tracing in the platform.

We do that using the following Maven dependency:

<dependency>
    <groupId>io.opentracing.contrib</groupId>
    <artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
    <version>2.0.3</version>
</dependency>

And it is working pretty well, we can see the trace on the Jaeger UI web console.

The problem now is how to send the tracking information to the next inner service in the platform to have every service correlated.

Any ideas?

We have tried to inject the tracking information as HTML Headers using a GlobalFilter but it is using the incoming request and we need to put them on the downstream request... any clue on how to override HTTPClient used underneath.

@Bean
@Order(-1)
public GlobalFilter tracingFilter() {
    return (exchange, chain) -> {
        ServerHttpRequest request = exchange.getRequest();

        Tracer tracer = TracerResolver.resolveTracer();
        Span span = tracer.buildSpan(request.getMethod().toString())
                .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
                .start();

        Tags.HTTP_URL.set(span, request.getURI().toString());
        Tags.HTTP_METHOD.set(span, request.getMethod().toString());
        if (request.getURI().getPort() != -1) {
            Tags.PEER_PORT.set(span, request.getURI().getPort());
        }

        ServerHttpRequest.Builder requestBuilder = request.mutate();

        tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new RequestBuilderCarrier(requestBuilder));

        ...

        }));
    };
}
NOrbes
  • 61
  • 6

0 Answers0