-
Notifications
You must be signed in to change notification settings - Fork 1k
Update jdbc doc with connection wrapping disclaimer #14884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,23 @@ | |
| `otel.instrumentation.jdbc.statement-sanitizer.enabled` | Boolean | `true` | Enables the DB statement sanitization. | | ||
| `otel.instrumentation.jdbc.experimental.capture-query-parameters` | Boolean | `false` | Enable the capture of query parameters as span attributes. Enabling this option disables the statement sanitization. <p>WARNING: captured query parameters may contain sensitive information such as passwords, personally identifiable information or protected health info. | | ||
| `otel.instrumentation.jdbc.experimental.transaction.enabled` | Boolean | `false` | Enables experimental instrumentation to create spans for COMMIT and ROLLBACK operations. | | ||
|
||
## Connection Pool Unwrapping | ||
|
||
The JDBC instrumentation unwraps pooled connections to cache database metadata efficiently. Most | ||
connection pools support this by default. | ||
|
||
**Performance issue?** If unwrapping fails, database metadata is extracted on every operation | ||
instead of being cached, causing higher CPU usage. To fix, ensure your connection pool supports | ||
unwrapping: | ||
|
||
**Vibur DBCP example:** | ||
```java | ||
ds.setAllowUnwrapping(true); | ||
``` | ||
|
||
**Custom wrappers:** Implement `java.sql.Wrapper` correctly to delegate `isWrapperFor()` and | ||
`unwrap()` to the underlying connection. | ||
|
||
|
||
**Failover note:** Cached metadata uses the unwrapped connection object as the key. If your pool | ||
reuses the same connection object after failover, telemetry may show stale host attributes. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will require more careful wording. CPU usage isn' the real issue. The problem is that calling
getMetaData
may result in querying database (what this method does depends on the database driver, also the driver may cache the results). I'd suggests you to rephrase with emphasis on that instrumentation requires that connections can be unwrapped and that inability to unwrap may cause degraded performance or have increased overhead with some jdbc drivers. Below you also mention that unwrapping is needed for attributing work to correct connection. There was recently an issue with shardingsphere where we showed the wrong database for some queries.