2

I am following a micro-service based architecture for my service development. I want to trace each of my request through various microservice calls in my system. My microservices are communicating over Google PubSub messaging framework. I am not able to find any out of the box way to pass on the MDC context to my subsequent service calls. I am using spring Sleuth for tracing. Is there any way I can pass the MDC context over PubSub calls?

Ady
  • 584
  • 8
  • 16

1 Answers1

1

If by "MDC" you mean tracing context then you can e.g. use Spring Cloud Stream with Google PubSub that would work out of the box. If you need to do it manually then you can access the current span from the Tracer bean, via tracer.currentSpan() and from its SpanContext you can retrieve the trace id and span id that you should pass to the Google PubSub message.

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
  • Using spring-cloud-starter-sleuth y spring-integration-core ... it does not works out of the box. May you please clarify? – Rafael Jan 27 '23 at 16:03