5

I am new to Jaeger and I would like to use it in order to record traces for my microservices.

I create traces from my μservices, providing the traceId publish them as messages and consume them in another service in order to export the trace to Jaeger. Though I have not found a way to provide also the span id and control them from the producer side.

  1. Should I save some sort of state e.g.(the parent span of each trace) in my consumer, so that I can have correct hierarchy? How would you go about that?

  2. My current setup has the order set by the ones that complete first and not by those that start first which is the desired. The API should be the first one. Do you know how I can solve this?

Jaeger

Any ideas or feedback are highly appreciated.

Giorgos Ntymenos
  • 361
  • 2
  • 13

1 Answers1

0

To create a new span for a given trace ID, you need to use the Jaeger client library for your language and follow the OpenTracing API specification. According to answer on StackOverflow, you can get the span ID from the span at your service1 and propagate it to your other services. For example, in Spring Boot:

// service1
JaegerSpan span = tracer.buildSpan ("service1")
String spanId = span.context ().toTraceId ()

// service2
JaegerSpanContext context = new JaegerSpanContext (traceId, spanId, 0L, (byte) 0);
JaegerSpan span = tracer.buildSpan ("service2").asChildOf (context).start ();

You can also use the OpenTelemetry API to create spans and export them to Jaeger using a specific transformation. You need to convert the bytes of the IDs to unsigned ints using Big Endian byte order..

If you are new - I can suggest you to start with some tutorials on the web

xakepp35
  • 2,878
  • 7
  • 26
  • 54
  • Hi thanks a lot for the answer, although this is applicable when you have Jaeger in every microservice, in contrast with my approach which I only use Jaeger in my consumer. – Giorgos Ntymenos Apr 05 '23 at 14:45
  • 1
    Please do not Jaeger Client, that was deprecated (https://www.jaegertracing.io/docs/1.43/client-libraries/). Use OpenTelemetry instead. – Juliano Costa Apr 07 '23 at 05:21