Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
289 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...