# How to add custom trace id generator in elastic APM java agent code base

**URL:** https://discuss.elastic.co/t/how-to-add-custom-trace-id-generator-in-elastic-apm-java-agent-code-base/348360
**Category:** APM
**Tags:** java
**Created:** [November 30, 2023, 6:57pm UTC](https://discuss.elastic.co/t/how-to-add-custom-trace-id-generator-in-elastic-apm-java-agent-code-base/348360 "2023-11-30T18:57:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![MadhusudanN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/madhusudann/32/128332_2.png) [@MadhusudanN](https://discuss.elastic.co/u/MadhusudanN)
#### Post date: [November 30, 2023, 6:57pm UTC](https://discuss.elastic.co/t/how-to-add-custom-trace-id-generator-in-elastic-apm-java-agent-code-base/348360/1 "2023-11-30T18:57:59Z")

</div>

Can someone please let me know if there is a way to plug custom trace id generator in the elastic APM java agent code base.

---

<div class="post-metadata">

### Author: ![Jonas\_Kunz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonas_kunz/32/110740_2.png) [@Jonas\_Kunz](https://discuss.elastic.co/u/Jonas_Kunz)
#### Post date: [December 1, 2023, 11:52am UTC](https://discuss.elastic.co/t/how-to-add-custom-trace-id-generator-in-elastic-apm-java-agent-code-base/348360/2 "2023-12-01T11:52:14Z")

</div>

Currently there is no way to customize the trace-ID generation in the elastic apm generator.

You could alternatively use the OpenTelemetry java agent with a custom extension which [configures the IDGenerator](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure-spi/src/main/java/io/opentelemetry/sdk/autoconfigure/spi/AutoConfigurationCustomizer.java#L108).

May I ask what you are trying to achieve? Maybe we can propose a different solution.

---

<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: [December 29, 2023, 11:52am UTC](https://discuss.elastic.co/t/how-to-add-custom-trace-id-generator-in-elastic-apm-java-agent-code-base/348360/3 "2023-12-29T11:52:44Z")

</div>

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