Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while starting prometheus metrics exporter #5401

Closed
BodySplash opened this issue Feb 18, 2022 · 1 comment · Fixed by #5408
Closed

Error while starting prometheus metrics exporter #5401

BodySplash opened this issue Feb 18, 2022 · 1 comment · Fixed by #5408
Labels
bug Something isn't working regression

Comments

@BodySplash
Copy link

BodySplash commented Feb 18, 2022

Describe the bug
While using opentelemtry agent, when configured to use prometheus as metrics exporter, it crashed with these error :

ERROR io.opentelemetry.javaagent.OpenTelemetryAgent
java.lang.NoClassDefFoundError: com/sun/net/httpserver/HttpHandler
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:375)
        at io.opentelemetry.sdk.autoconfigure.ClasspathUtil.checkClassExists(ClasspathUtil.java:15)
        at io.opentelemetry.sdk.autoconfigure.MetricExporterConfiguration.configurePrometheusMetricReader(MetricExporterConfiguration.java:164)
        at io.opentelemetry.sdk.autoconfigure.MetricExporterConfiguration.configureExporter(MetricExporterConfiguration.java:40)
        at io.opentelemetry.sdk.autoconfigure.MeterProviderConfiguration.configureMeterProvider(MeterProviderConfiguration.java:43)
        at io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder.build(AutoConfiguredOpenTelemetrySdkBuilder.java:313)
        at io.opentelemetry.javaagent.tooling.OpenTelemetryInstaller.installOpenTelemetrySdk(OpenTelemetryInstaller.java:43)
        at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:124)
        at io.opentelemetry.javaagent.tooling.AgentInstaller.installBytebuddyAgent(AgentInstaller.java:95)
        at io.opentelemetry.javaagent.tooling.AgentStarterImpl.start(AgentStarterImpl.java:65)
        at io.opentelemetry.javaagent.bootstrap.AgentInitializer.initialize(AgentInitializer.java:35)
        at io.opentelemetry.javaagent.OpenTelemetryAgent.startAgent(OpenTelemetryAgent.java:55)
        at io.opentelemetry.javaagent.OpenTelemetryAgent.premain(OpenTelemetryAgent.java:44)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:491)
        at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:503)
Caused by: java.lang.ClassNotFoundException: com.sun.net.httpserver.HttpHandler
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at io.opentelemetry.javaagent.bootstrap.AgentClassLoader.findClass(AgentClassLoader.java:151)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
        at io.opentelemetry.javaagent.bootstrap.AgentClassLoader.loadClass(AgentClassLoader.java:132)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
        ... 20 more

Steps to reproduce

Run any given java process with the classical agent configuration:

-javaagent:/Users/jb/Downloads/opentelemetry-javaagent-1.11.0.jar \ 
-Dotel.metrics.exporter=prometheus \
-Dotel.traces.exporter=logging \
-Dotel.exporter.prometheus.port=9464

What did you expect to see?
To be able to get metrics through the configured port.

What did you see instead?
The error message, and no http server running

What version are you using?
v1.11.0

Environment
Compiler: "Temurin 17.0.2"
OS: "MacOS 12.1"

Additional context
The issue is not present in agent version 1.10.1
Also, I had a quick look at the current MetricExporterConfiguration.configurePrometheusMetricReader
implementation, and checkClassExists is not called for HttpHandler. So maybe it's just an issue with the version distributed inside the agent ?

@BodySplash BodySplash added the bug Something isn't working label Feb 18, 2022
@laurit
Copy link
Contributor

laurit commented Feb 18, 2022

Regression from #5169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression
Projects
None yet
3 participants