-
Add x-b3-traceid inject to message header pass to other serviceHi everyone, I have a problem about tracing on rabbitmq message by i have three service ┌──────────────────┐ ┌──────────────────┐ ┌───────────────┐
│ │ │ │ │ │
│ service a │ queue │ service b │ queue │ service c │
│ (springboot) │ ─────────────►│ (golang) │ ─────────►│ (golang) │
│ │ │ │ │ │
└──────────────────┘ └──────────────────┘ └───────────────┘
▼ My problem is service b cannot get traceID to connect from service a but i don't confident with code below Tracer trace = tracer.tracerBuilder("rabbitmq").build();
Span span = trace.spanBuilder("rabbitmq-process").startSpan();
CorrelationData correlationData = new CorrelationData();
long generateCreatedTime = System.nanoTime();
correlationData.setId("12345678");
rabbitTemplate.convertAndSend(
"test",
"created",
"testing from dream",
m -> {
m.getMessageProperties().setHeader("X-B3-TraceId", span.getSpanContext().getTraceId());
m.getMessageProperties().setHeader("X-B3-SpanId", span.getSpanContext().getSpanId());
if (span.getSpanContext().isSampled()){
m.getMessageProperties().setHeader("X-B3-Sampled",1);
}
m.getMessageProperties().setHeader("x-timestamp", generateCreatedTime);
return m;
},
correlationData
); |
Beta Was this translation helpful? Give feedback.
Answered by
jkwatson
Jun 7, 2022
Replies: 1 comment 2 replies
-
I'm not sure what your problem might be, but I do recommend using our provided B3 propagator for this functionality, rather than rebuilding it. You can find a link to the propagators in our documentation: https://github.com/open-telemetry/opentelemetry-java#api-extensions. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
voratham
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure what your problem might be, but I do recommend using our provided B3 propagator for this functionality, rather than rebuilding it. You can find a link to the propagators in our documentation: https://github.com/open-telemetry/opentelemetry-java#api-extensions.