With the Elastic APM Java Agent API you can add lables and custom context to an in-progress transaction and/or span.
Is it possible to add a label that will be used for the next, or all transactions, on the current thread?
Similar to using logback's MDC.
I'm guessing adding them to a No-Op Span doesn't work.
Why is adding labels to an existing transaction not sufficient?
Because I'd have to repeat the same code in many places. It would be better if I could add it in a single place before any instrumented methods are called.
It's a non-HTTP request-based protocol. The connection is established and a thread assigned to it before any requests (i.e. transactions) begin. There will be many request of different types on each connection. I want to add details of the connection to the recorded transactions. I don't want to have to add code to do this in every single different request-handling method.
Which protocol and framework are you using? Is that something homegrown or an open source framework? Most frameworks have a way to register filters/interceptors. Is that possible with the framework you are using?
In that case I would suggest to either add interceptor capabilities to that or to use Byte Buddy or some other bytecode manipulation/aspect oriented programing framework like AspectJ or Spring AOP to achieve something similar without requiring code changes.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.