How to use same instance of Prometheus default registry in agent as well as in application #6912
-
Hello, I am building a custom agent using is distro approach mentioned here https://github.com/open-telemetry/opentelemetry-java-instrumentation/tree/main/examples/distro. This custom agent will be statically attached (using Our requirement is to emit a prometheus metric on a special span start. To achieve this, I have added a custom SpanProcessor The custom MetricEmitSpanProcessor code is:
I have also tried loading
This didn't work too. I expected this to work since
I don't have much experience in dealing with class loaders, I tried multiple ways to achieve this behavior but in vain How can I achieve this behaviour of same prometheus default registry object |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
AgentClassLoader
uses child first delegation, if a class is present ininst
it will be loaded by agent class loader regardless of whether bootstrap loader can also load it. This exception means that you have probably packaged prometheus classes in agent ininst
directory (loaded by agent class loader) and also at the root of the jar (loaded by bootstrap loader). Check you agent jar and remove the prometheus classes frominst
.