dd-trace-java icon indicating copy to clipboard operation
dd-trace-java copied to clipboard

Support for R2DBC

Open lvitaly opened this issue 2 years ago • 17 comments

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

lvitaly avatar Feb 06 '23 17:02 lvitaly

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!

jurriaan avatar Sep 13 '23 13:09 jurriaan

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.

d-wire avatar Oct 31 '23 17:10 d-wire

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

TheBatman09 avatar Nov 16 '23 09:11 TheBatman09

Any updates or work arounds for this issue?

ahmadwrites avatar Dec 07 '23 02:12 ahmadwrites

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

bm1549 avatar Dec 07 '23 23:12 bm1549

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?

ahmadwrites avatar Dec 11 '23 08:12 ahmadwrites

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 🤞

d-wire avatar Feb 14 '24 15:02 d-wire

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.

mcculls avatar Aug 25 '24 22:08 mcculls