JDBC OpenTelemetryStatement#getConnection()
Doesn't Return Wrapped Connection
#10550
Labels
OpenTelemetryStatement#getConnection()
Doesn't Return Wrapped Connection
#10550
Describe the bug
We're using OpenTelemetry's JDBC data source instrumentation library to wrap and instrument our JDBC connections. However, when getting the connection used for a
PreparedStatement
, the library returns the underlying connection rather than the wrapped, Otel-provided connection.In a very narrow case, with:
JdbcTemplate#queryForStream
Spring will call
OpenTelemetryStatement#getConnection()
, receive the non-wrapped connection, and through reference checks that return false, mistakenly close the connection.Instead,
OpenTelemetryStatement#getConnection()
should return the wrapped connection that created the Statement rather than deferring to its delegate.Steps to reproduce
(executing within this Otel test)
The assertion fails when I'd expect it to succeed.
Expected behavior
OpenTelemetryStatement#getConnection()
returns the wrapped connection (OpenTelemetryConnection
) that's the same wrapped connection used to create the statement.Actual behavior
OpenTelemetryStatement#getConnection()
returns the underlying connection rather than the wrapped connection.Javaagent or library instrumentation version
v1.31.1
Environment
JDK: Corretto 17
OS: macOS / Amazon Linux 2023
Additional context
No response
The text was updated successfully, but these errors were encountered: