MDC integration

Hi,
I am just diving into the deep sea of APM, and the possibilites that comes with the Elastic APM agent, which my team has been using for a while, but just what comes out of the box.

In my current setup, I am adding custom baggage that is being propagated between my applications, thanks to the apm agent. I can then move this baggaged data to the slf4j MDC.

I have, however, one problem in one of the applications. This application is multithreaded. The agent inserts the trace.id and transaction.id just fine into the new threads MDC, but my custom data, I have to move by myself.

Are there any plans on opening up the integration between the agent and the MDC so I can have my custom data inserted to the MDC just as the agent inserts the other, known, data?

Right now it is rather "boilerplaty" to get the values from MDC before a task is submitted to my executorservice, and then open up a new MDCCloseable-scope moving the values over.

Hi,

As you are referring to "baggage" I guess that you are using opentelemetry baggage for which we added support in version 1.41.0 of the java agent.

The agent only takes care of its own values in the MDC, so that is expected that only the trace.id and transaction.id are automatically propagated to the MDC.

If you want to make your own attributes propagated to the MDC you have to do it on your own as if the agent would not be there.
From what I understand here you:

  • set your custom values in slf4j MDC
  • would like the MDC values are automatically propagated from one thread to another with the same heuristic as the agent propagates its own IDs (this process is what we usually call context-propagation).

Is my understanding correct here ?

Yes, your understanding is correct. Thanks for clarifying.

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