JoJo46
JoJo46

Reputation: 31

spring boot starter opentelemetry getting ClasNotFound for DoubleGauge

so I can't even seem to find what library contains this, but for the spring-boot-starter-opentelemetry, when booting up Spring Boot, I get the following error.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autoConfiguredOpenTelemetrySdk' defined in class path resource [io/opentelemetry/instrumentation/spring/autoconfigure/OpenTelemetryAutoConfiguration$OpenTelemetrySdkConfig.class]: Failed to instantiate [io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk]: Factory method 'autoConfiguredOpenTelemetrySdk' threw exception with message: io/opentelemetry/api/incubator/metrics/DoubleGauge
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:648) ~[spring-beans-6.1.11.jar:6.1.11]
    ...
    ... 133 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk]: Factory method 'autoConfiguredOpenTelemetrySdk' threw exception with message: io/opentelemetry/api/incubator/metrics/DoubleGauge
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:178) ~[spring-beans-6.1.11.jar:6.1.11]
    ...
    ... 148 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.metrics.DoubleGauge
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[na:na]
    ... 166 common frames omitted

I'm using gradle, with the toml entries being

spring-boot-starter-opentelemetry = {group = "io.opentelemetry.instrumentation", name = "opentelemetry-spring-boot-starter", version = { ref = "opentelemetry" }}
spring-boot-starter-opentelemetry-bom = {group = "io.opentelemetry.instrumentation", name = "opentelemetry-instrumentation-bom", version = { ref = "opentelemetry" }}

...

opentelemetry = "2.7.0"

And the gradle dependency setup with

plugins { 
    alias(libs.plugins.dependency.management)
}
        
plugins.apply(libs.plugins.dependency.management.get().pluginId)
dependencyManagement {
    imports {
        ...
        mavenBom(libs.spring.boot.starter.opentelemetry.bom.get().toString())
        mavenBom(SpringBootPlugin.BOM_COORDINATES)
    }
    dependencies {
        ...
    }
}

I'm using the two micrometer packages, namely micrometer-tracing and micrometer-tracing-bridge-otel. As well as the standard actuator and web spring boot startups

I just can't seem to find that class on Google at all to even try to explicitly include the library it seems to be missing. I removed all configuration and left it at default as well thinking maybe there was a conditional I just wasn't seeing within the otel series of config options, but nothing is getting rid of this ClassNotFoundException

I basically just followed the instructions here, with the issues stated earlier.

Upvotes: 3

Views: 1523

Answers (1)

JoJo46
JoJo46

Reputation: 31

Ok so for anyone else having this issue, at least for my setup, the BOM was not explicitly setting the right opentelemetry-api-incubator version. It was pulling the latest and greatest when left to it's own devices, which has removed DoubleGauge, while the 1.37.0-alpha version does have DoubleGauge. Everything else seems to set 1.37.0 explicitly when looking at a dependency analyzer which is why I'm wondering if this is perhaps a bug in the BOM setup though I really can't say since I wasn't seeing the issue when searching for it earlier.

But yeah, bottom line, set maven or gradle or whatever you use to explicitly use the 1.37.0-alpha version if you are using version 2.7.0 or below of the opentelemetry starter and that should fix your issue.

Upvotes: 0

Related Questions