# How do we instrument application which uses LMAX Disruptor

**URL:** <https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908>\
**Category:** APM\
**Tags:** java\
**Created:** [July 4, 2019, 11:57am UTC](https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908 "2019-07-04T11:57:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gajanan8086](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gajanan8086/32/50604_2.png) [@gajanan8086](https://discuss.elastic.co/u/gajanan8086)\
**Post date:** [July 4, 2019, 11:57am UTC](https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908/1 "2019-07-04T11:57:00Z")

</div>

How do we instrument application which uses LMAX Disruptor.

I have jms components which are now instrumented with jms plugin but the consumer uses LMAX Disruptor for further processing and then forward down to next component using JMX.

We can think of having instrumentation plugin for LMAX Disruptor but as the agent uses Disruptor internally we might end up instrumenting agent itself.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [July 4, 2019, 12:08pm UTC](https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908/2 "2019-07-04T12:08:57Z")

</div>

Hi and welcome to the forum!

This sounds like an interesting idea!  
Since we shade the library classes we use as dependencies, all Disruptor classes will be shaded as well and loaded in runtime under the package `co.elastic.apm.agent.shaded.lmax`, so as long as you match for the fully qualified class names, there shouldn't be a clash.

Would you like to contribute this as an agent plugin?

---

<div class="post-metadata">

**Author:** ![gajanan8086](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gajanan8086/32/50604_2.png) [@gajanan8086](https://discuss.elastic.co/u/gajanan8086)\
**Post date:** [July 23, 2019, 4:30pm UTC](https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908/3 "2019-07-23T16:30:10Z")

</div>

I believe the maven shaded plugin will also replace the references used for instrumenting LMAX with original package names.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [July 28, 2019, 9:18am UTC](https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908/4 "2019-07-28T09:18:25Z")

</div>

Well, there are multiple ways to deal with that.

For anything you want to use as String (eg identifying whether a class has a specific name), you can just split the String setting into two concatenated Strings. Since the shading happens on source code, it won't be able to recognize that. You can see an example with [our slf4j MDC plugin](https://github.com/elastic/apm-agent-java/blob/45857cea69a82ac97d5f1bee266f58fbedddb43e/apm-agent-plugins/apm-slf4j-plugin/src/main/java/co/elastic/apm/agent/slf4j/Slf4JMdcActivationListener.java#L45).

For anything you want to use as a real type, I would investigate what can be achieved with the [Maven shade plugin filtering configurations](https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html), then change the current pom to shade only the specific classes agent directly depends on or specifically avoid shading the classes you instrument (the latter is preferable).

The other option is to use the public API to do the context propagation. For more details see [this topic about doing the same with BlockingQueues](https://discuss.elastic.co/t/java-apm-client-transfer-transaction-information-when-using-blockingqueue-instead-of-executorservice/191781) and [the PR that demonstrates that](https://github.com/elastic/apm-agent-java/pull/754). The same concept should apply here as well.

I hope this helps,  
Eyal.

---

<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 18, 2019, 5:18am UTC](https://discuss.elastic.co/t/how-do-we-instrument-application-which-uses-lmax-disruptor/188908/5 "2019-08-18T05:18:33Z")

</div>

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