How do we instrument application which uses LMAX Disruptor

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.

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?

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

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.

For anything you want to use as a real type, I would investigate what can be achieved with the Maven shade plugin filtering configurations, 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 and the PR that demonstrates that. The same concept should apply here as well.

I hope this helps,
Eyal.

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