DataDog / dd-trace-java

Datadog APM client for Java
https://docs.datadoghq.com/tracing/languages/java
Apache License 2.0
564 stars 282 forks source link

Support for R2DBC #4673

Open lvitaly opened 1 year ago

lvitaly commented 1 year ago

R2DBC project reached 1.0 release and already has support for popular databases such as Oracle, PostgreSQL, MySQL, H2, MsSQL, and MariaDB. R2DBC provides a nice feature for observability as r2dbc-proxy. But anyway, it would be nice to have instrumentation out of the box.

https://r2dbc.io

jurriaan commented 11 months ago

OpenTelemetry also solves this using a ProxyConnectionFactory: https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/r2dbc-1.0/library/README.md

Hoping this can be added to dd-trace-java as well!

d-wire commented 10 months ago

Any chance there's an update on this? It'd be really nice to have r2dbc support in our DataDog traces, since the current behavior spawns a new trace id every time an r2dbc operation is performed.

TheBatman09 commented 9 months ago

Do you have a workaround to avoid generating a new trace id each time ? I have the same issue.

ahmadwrites commented 9 months ago

Any updates or work arounds for this issue?

bm1549 commented 9 months ago

Hello 👋 Brian from Datadog here

Unfortunately, there are no updates on R2DBC support at this time. That being said, we'll be sure to update this issue when we make progress

ahmadwrites commented 8 months ago

Any chance there's an update on this? It'd be really nice to have r2dbc support in our DataDog traces, since the current behavior spawns a new trace id every time an r2dbc operation is performed.

Have you found any workaround?

d-wire commented 6 months ago

Any chance there's an update on this? It'd be really nice to have r2dbc support in our DataDog traces, since the current behavior spawns a new trace id every time an r2dbc operation is performed.

Have you found any workaround?

Not yet unfortunately. Still hoping for full support for r2dbc at this point 🤞

mcculls commented 1 week ago

Hi - since 1.38.1 you can now add the OTel R2DBC instrumentation at runtime to dd-java-agent: https://docs.datadoghq.com/opentelemetry/interoperability/instrumentation_libraries/?tab=java

For example:

# this demo requires Java 21 and Maven 3 on your PATH
git clone https://github.com/eugenp/tutorials

cd tutorials/spring-reactive-modules/spring-reactive-data

curl -L -O https://github.com/DataDog/dd-trace-java/releases/download/v1.38.1/dd-java-agent-1.38.1.jar

curl -L -O \
    https://repo1.maven.org/maven2/io/opentelemetry/javaagent/instrumentation/opentelemetry-javaagent-r2dbc-1.0/2.5.0-alpha/opentelemetry-javaagent-r2dbc-1.0-2.5.0-alpha.jar

mvn spring-boot:run \
    -Dstart-class=com.baeldung.pagination.PaginationApplication \
    -Dspring-boot.run.jvmArguments="-javaagent:dd-java-agent-1.38.1.jar \
        -Ddd.trace.otel.enabled=true \
        -Dotel.javaagent.extensions=opentelemetry-javaagent-r2dbc-1.0-2.5.0-alpha.jar"

Open http://127.0.0.1:8080/products to exercise the product query - you should see R2DBC spans in the Datadog UI

Note that we currently only support versions up to 2.5.0-alpha of the R2DBC instrumentation. This is because in 2.6.0-alpha OTel refactored some of the instrumentation config classes and we need to adjust our mappings to account for that.