# Sleuth and Java APM Agent using the same Trace/Span ids

**URL:** <https://discuss.elastic.co/t/sleuth-and-java-apm-agent-using-the-same-trace-span-ids/191108>\
**Category:** APM\
**Tags:** java\
**Created:** [July 17, 2019, 11:09pm UTC](https://discuss.elastic.co/t/sleuth-and-java-apm-agent-using-the-same-trace-span-ids/191108 "2019-07-17T23:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![talenko](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@talenko](https://discuss.elastic.co/u/talenko)\
**Post date:** [July 17, 2019, 11:09pm UTC](https://discuss.elastic.co/t/sleuth-and-java-apm-agent-using-the-same-trace-span-ids/191108/1 "2019-07-17T23:09:12Z")

</div>

Hello,

This might be a vague question, so please bare with me. I am trying to integrate APM with our current distributed tracing stack involving Spring Cloud Sleuth. Essentially, I registered an OpenTracing tracer bean which uses the `ElasticApmTracer` instance; however, it seems as though Sleuth and the APM tracers are working independently and so I observe different trace/span ids for the same micro-service request.

My question is, is there any docs I could be pointed to that somewhat hint at how to accomplish should a task of incorporating say a current distributed tracing tool like Sleuth with APM so that they both are in synergy?

Thanks

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 18, 2019, 7:13am UTC](https://discuss.elastic.co/t/sleuth-and-java-apm-agent-using-the-same-trace-span-ids/191108/2 "2019-07-18T07:13:43Z")

</div>

Hi and welcome to the forum 🙂

This is probably due to the fact that Elastic APM and Sleuth use different headers to propagate the context. IIRC, Sleuth uses B3 headers, whereas Elastic APM uses `elastic-apm-traceparent` which is a variant of the W3C spec draft for the `traceparent` header.

See [https://github.com/elastic/apm/issues/116](https://github.com/elastic/apm/issues/116) for more information.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 8, 2019, 3:25am UTC](https://discuss.elastic.co/t/sleuth-and-java-apm-agent-using-the-same-trace-span-ids/191108/3 "2019-08-08T03:25:35Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
