Skip to content

Commit 1177919

Browse files
committed
Update jdbc doc with connection wrapping disclaimer
1 parent 03b8ad5 commit 1177919

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

docs/instrumentation-list.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4735,6 +4735,7 @@ libraries:
47354735
- name: jdbc
47364736
description: |
47374737
The JDBC instrumentation provides database client spans and metrics. Each call produces a span named after the SQL verb, enriched with standard DB client attributes (system, database, operation, sanitized statement, peer address) and error details if an exception occurs.
4738+
The instrumentation unwraps pooled connections to cache database metadata. If your connection pool doesn't support unwrapping (java.sql.Wrapper), metadata extraction will occur on every operation, causing higher CPU usage.
47384739
There is also a "jdbc-datasource" instrumentation that creates spans for datasource connections, but is disabled by default due to the volume of telemetry produced.
47394740
library_link: https://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.html
47404741
source_path: instrumentation/jdbc

instrumentation/jdbc/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,23 @@
55
| `otel.instrumentation.jdbc.statement-sanitizer.enabled` | Boolean | `true` | Enables the DB statement sanitization. |
66
| `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. |
77
| `otel.instrumentation.jdbc.experimental.transaction.enabled` | Boolean | `false` | Enables experimental instrumentation to create spans for COMMIT and ROLLBACK operations. |
8+
9+
## Connection Pool Unwrapping
10+
11+
The JDBC instrumentation unwraps pooled connections to cache database metadata efficiently. Most
12+
connection pools support this by default.
13+
14+
**Performance issue?** If unwrapping fails, database metadata is extracted on every operation
15+
instead of being cached, causing higher CPU usage. To fix, ensure your connection pool supports
16+
unwrapping:
17+
18+
**Vibur DBCP example:**
19+
```java
20+
ds.setAllowUnwrapping(true);
21+
```
22+
23+
**Custom wrappers:** Implement `java.sql.Wrapper` correctly to delegate `isWrapperFor()` and
24+
`unwrap()` to the underlying connection.
25+
26+
**Failover note:** Cached metadata uses the unwrapped connection object as the key. If your pool
27+
reuses the same connection object after failover, telemetry may show stale host attributes.

instrumentation/jdbc/metadata.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ description: >
22
The JDBC instrumentation provides database client spans and metrics. Each call produces a span
33
named after the SQL verb, enriched with standard DB client attributes (system, database,
44
operation, sanitized statement, peer address) and error details if an exception occurs.
5-
5+
6+
The instrumentation unwraps pooled connections to cache database metadata. If your connection pool
7+
doesn't support unwrapping (java.sql.Wrapper), metadata extraction will occur on every operation,
8+
causing higher CPU usage.
9+
610
There is also a "jdbc-datasource" instrumentation that creates spans for datasource connections,
711
but is disabled by default due to the volume of telemetry produced.
812
library_link: https://docs.oracle.com/javase/8/docs/api/java/sql/package-summary.html

0 commit comments

Comments
 (0)