Question: extent of bytecode instrumentation

Hello everyone,

the company I'm working in is using kibana for a couple of years now. Over the past year we had issues with monitoring the health of our application ( tracking errors and performance). Because of that I would like to introduce kibana APM.

I already had talks with one of our lead developers, who issued some questions/concerns depending the bytecode instrumentation. To overcome these concerns and to ease the adoption I would like to know what kind of code is injected.

I tried to read the code base of the java apm agent (GitHub - elastic/apm-agent-java). As someone who has no experience with java instrumentation its quite hard for me to understand what is happening.

Could someone explain what code exactly is injected or give some reference to the relevant places in the apm-agent code where the code injection happens?

First of all, as it looks like you are starting from scratch we'd recommend you to use OpenTelemetry for the data collection instead. You can have a look at our Elastic Distribution of the OpenTelemetry java Agent which is designed to provide the best experience for our Kibana UIs.

Regarding your question about what code exactly is inserted: You can look in the vanilla OpenTelemetry Java Agent for all implementations of the TypeInstrumentation: Those define exactly which methods are instrumented and what code is inserted using the ByteBuddy Advice mechanism.

If you have concerns about bytecode-instrumentation, you can also use the OpenTelemetry SDK and just perform manual instrumentation.

2 Likes

Not a technical answer, and it's always OK to ask questions and air concerns, better that way in fact, but its not a wide river between airing understandable caution and just not wanting others having insight into application performance/stability.

There's a number of Youtube videos introducing OpenTelemetry, many discussing the java instrumentation implementation, at least in general terms. But without getting deep into the weeds, you're not going to get much detail on the actual byte code injected, best you can really hope for is a broad description of its intention and use. Of course there is also the possibility of adding your manual instrumentation, which would be your own instrumentation code (well, sort of anyways).

Good luck!

1 Like

Thank you for your replies. I'll look into the OpenTelemetry Java Agent.

Not a technical answer, and it's always OK to ask questions and air concerns, better that way in fact, but its not a wide river between airing understandable caution and just not wanting others having insight into application performance/stability.

I agree, however, in our case its not entirely up to us. The project is for a customer in the public sector, because of that we have some hard constraints.