open-telemetry / opentelemetry-java-instrumentation

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

tracing for spring-data-r2dbc Spring Data repository methods is timed incorrectly #9500

Closed 62mkv closed 11 months ago

62mkv commented 11 months ago

Describe the bug

it looks like traces collected for Spring Data repositories, are reflecting just "assembly" phase; they typically are measured in microseconds (μs), whereas the "containing" spans (such as WebFlux GET etc) are measured in milliseconds.

in order to represent meaningful performance-related picture; instrumentation must understand if a return type of a Spring Data repository method is a Publisher (Mono/Flux) and adjust span start/stop accordingly

Steps to reproduce

I can probably built a reproduction test case but really, any Spring Boot 2.7 project with spring-data-r2dbc and io.opentelemetry.spring-data-1.8 will demonstrate this

Expected behavior

Span duration for spans collected by "io.opentelemetry.spring-data" instrumentation is not reflecting actual duration of an RDBMS operation

Actual behavior

Span duration for spans collected by "io.opentelemetry.spring-data" instrumentation is reflecting actual duration of an RDBMS operation(s)

Javaagent or library instrumentation version

https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.27.0/opentelemetry-javaagent.jar

Environment

JDK: Temurin 17.0.7+7 OS: Alpine Linux 5.10.147+

Additional context

No response

laurit commented 11 months ago

Please provide a minimal sample app that reproduces the issue.

62mkv commented 11 months ago

Finally got around to it: https://github.com/62mkv/opentelemetry-r2dbc-spring-data-sample

@laurit let me know if it worked for you 🙏

and thanks!

62mkv commented 11 months ago

wow!! this was faster then creating the reproducible project 😄 Thanks @laurit which release will it go under, 1.31? and when can this be expected to happen?

62mkv commented 11 months ago

Looks like it is expected to happen mid-October. Very good!

laurit commented 11 months ago

Should be available in snapshot build, pick the latest from https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/javaagent/opentelemetry-javaagent/1.31.0-SNAPSHOT/ Release cadence is described in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/RELEASING.md#release-cadence