Is there a way to find out if my application is running with the agent already active? #9173
-
I have an OpenTelemetry aware application that up until now I've programmatically used the AutoConfigureSdk and manual instrumentation via the OpenTelemetry API. Some libraries have been introduced, and I'd now like to consider just starting the application up with the agent and turning off agent instrumentation for the libraries we have already instrumented manually. Is there a way for my application to know that the agent is running? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think the easiest way is to
no
yes, use |
Beta Was this translation helpful? Give feedback.
-
By implementing an I have read over that section and seem to recall that Javaagent extensions are sandboxed and loaded with an isolated classLoader? And yes, I know that I shouldn't need to have access to the SDK anywhere else in my application - I think this is just trying to fit into some Otel legacy code where it was only possible to manually instantiate a logback OTLP appender by having access to the SDK to get a logEmitter. Incidentally, I did try copy/pasting the Object delegate = delegateField.get(openTelemetry); with
which I guess answers my question as to whether the OpenTelemetry API is shaded. |
Beta Was this translation helpful? Give feedback.
I think the easiest way is to
Class.forName("io.opentelemetry.javaagent.OpenTelemetryAgent")
or some other class that is present in the agent, and if it is found assume that you are running with the agent.no
yes, use
GlobalOpenTelemetry.get()