open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.94k stars 850 forks source link

JdbcInstrumentationAutoConfiguration incorrectly fires when using "org.springframework.boot:spring-boot-starter-data-redis" #11913

Closed trajano closed 2 months ago

trajano commented 2 months ago

Describe the bug

I have a simple test app that doesn't use Spring Data JPA or anything with JDBC. Adding the instrumentation fails

Steps to reproduce

add the following dependencies on a simple webflux app

org.springframework.boot:spring-boot-starter-webflux org.springframework.boot:spring-boot-starter-data-redis org.springframework.session:spring-session-data-redis

along with

implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.6.0")) implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")

Expected behavior

everything works

Actual behavior

"java.lang.IllegalStateException: Error processing condition on io.opentelemetry.instrumentation.spring.autoconfigure.internal.instrumentation.jdbc.JdbcInstrumentationAutoConfiguratiom"

Javaagent or library instrumentation version

2.6.0

Environment

JDK: OS:

Additional context

No response

trajano commented 2 months ago

https://github.com/trajano/simple-auth shows the error

trajano commented 2 months ago

Found the error I think you should remove the "platform" support for gradle in the documentation. That's what I did first, but Spring Boot starter always uses the dependency-management.

trask commented 2 months ago

Found the error I think you should remove the "platform" support for gradle in the documentation. That's what I did first, but Spring Boot starter always uses the dependency-management.

re-opening to see if there's something to improve in the docs

cc @jeanbisutti @zeitlinger

zeitlinger commented 2 months ago

this was the error

Caused by: java.lang.ClassNotFoundException: io.opentelemetry.sdk.autoconfigure.internal.ComponentLoader

because the dependency versions were not correct

+--- io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.6.0 | +--- io.opentelemetry:opentelemetry-bom:1.40.0 | | +--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.40.0 -> 1.31.0 (c) | | +--- io.opentelemetry:opentelemetry-api:1.40.0 -> 1.31.0 (c)

minimal setup

plugins {
    id("org.springframework.boot") version "3.2.5"
    id("io.spring.dependency-management") version "1.1.3"
    kotlin("jvm") version "1.8.22"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.6.0"))
    implementation("io.opentelemetry.instrumentation:opentelemetry-spring-boot-starter")
}

can be fixed by removing id("io.spring.dependency-management") version "1.1.3"

which is in line with our current docs - so nothing to do