Skip to content

Commit 719e84f

Browse files
implement OpenTelemetry stable semantic conventions
1 parent 59f3262 commit 719e84f

File tree

5 files changed

+727
-68
lines changed

5 files changed

+727
-68
lines changed

ojdbc-provider-observability/README.md

Lines changed: 117 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,112 @@ will publish these events into Open Telemetry. These events include:
1212
* AC begin and success
1313
* VIP down event
1414

15-
The following attributes are added the traces for each event:
16-
* **Roundtrips**
17-
* Connection ID
18-
* Database Operation
19-
* Database User
20-
* Database Tenant
21-
* SQL ID
22-
* Original SQL Text *(only present if sensitive data is enabled)*
23-
* Actual SQL Text *(only present if sensitive data is enabled)*
24-
* **AC begin and success**
25-
* Error Message
26-
* Error code
27-
* SQL state
28-
* Current replay retry count
29-
* **VIP down event**
30-
* Error message
31-
* VIP address
32-
* Protocol *(only present if sensitive data is enabled)*
33-
* Host *(only present if sensitive data is enabled)*
34-
* Port *(only present if sensitive data is enabled)*
35-
* Service name *(only present if sensitive data is enabled)*
36-
* SID *(only present if sensitive data is enabled)*
37-
* Connection data *(only present if sensitive data is enabled)*
15+
## Semantic Conventions (OpenTelemetry Tracer)
16+
17+
The OpenTelemetry tracer supports both **stable** and **experimental** (legacy)
18+
OpenTelemetry semantic conventions for Oracle Database instrumentation.
19+
20+
### Semantic Convention Migration
21+
22+
The OpenTelemetry tracer supports three modes controlled by the `OTEL_SEMCONV_STABILITY_OPT_IN`
23+
environment variable:
24+
25+
* **Empty/Not Set (default)** - Emits only experimental (legacy) conventions for backward compatibility
26+
* **`database`** - Emits only the new stable Oracle Database semantic conventions
27+
* **`database/dup`** - Emits both old and new conventions (dual mode for gradual migration)
28+
29+
This configuration can be set via environment variable or changed at runtime through the MBean interface.
30+
31+
See the [OpenTelemetry Database Semantic Conventions](https://opentelemetry.io/docs/specs/semconv/database/database-spans/)
32+
for details on the stable conventions.
33+
34+
### Roundtrip Events
35+
36+
#### Stable Conventions
37+
When `OTEL_SEMCONV_STABILITY_OPT_IN=database` or `database/dup`:
38+
39+
* **Required/Recommended Attributes**
40+
* `db.system.name` - Always set to `"oracle.db"`
41+
* `db.namespace` - Format: `{instance_name}|{database_name}|{service_name}`
42+
* `db.operation.name` - Database operation being executed
43+
* `db.query.summary` - Low cardinality query summary (SQL type)
44+
* `server.address` - Database server hostname
45+
* `server.port` - Database server port (if non-default, i.e., not 1521)
46+
* `oracle.db.query.sql.id` - Oracle SQL_ID
47+
* `oracle.db.session.id` - Oracle session ID
48+
* `oracle.db.server.pid` - Oracle server process ID
49+
* `oracle.db.shard.name` - Oracle shard name (if applicable)
50+
* `thread.id` - Current thread ID
51+
* `thread.name` - Current thread name
52+
53+
* **Opt-In Attributes** *(only present if sensitive data is enabled)*
54+
* `db.user` - Database user name
55+
* `db.query.text` - Actual SQL query text
56+
* `db.response.returned_rows` - Number of rows returned
57+
58+
* **Error Attributes** *(only present on errors)*
59+
* `error.type` - Exception class name (e.g., `java.sql.SQLSyntaxErrorException`)
60+
* `db.response.status_code` - Oracle error code (format: `ORA-XXXXX`)
61+
62+
#### Legacy Conventions
63+
When `OTEL_SEMCONV_STABILITY_OPT_IN` is empty/not set or `database/dup`:
64+
65+
* `Connection ID`
66+
* `Database Operation`
67+
* `Database Tenant`
68+
* `SQL ID`
69+
* `thread.id`
70+
* `thread.name`
71+
* `Database User` *(only present if sensitive data is enabled)*
72+
* `Original SQL Text` *(only present if sensitive data is enabled)*
73+
* `Actual SQL Text` *(only present if sensitive data is enabled)*
74+
75+
### Application Continuity (AC) Replay Events
76+
77+
#### Stable Conventions
78+
When `OTEL_SEMCONV_STABILITY_OPT_IN=database` or `database/dup`:
79+
80+
* `db.system.name` - Always set to `"oracle.db"`
81+
* `error.type` - Error message that triggered replay
82+
* `db.response.status_code` - Oracle error code (format: `ORA-XXXXX`)
83+
* `db.operation.batch.size` - Current replay retry count
84+
85+
#### Legacy Conventions
86+
When `OTEL_SEMCONV_STABILITY_OPT_IN` is empty/not set or `database/dup`:
87+
88+
* `Error Message`
89+
* `Error code`
90+
* `SQL state`
91+
* `Current replay retry count`
92+
93+
### VIP Retry Events
94+
95+
#### Stable Conventions
96+
When `OTEL_SEMCONV_STABILITY_OPT_IN=database` or `database/dup`:
97+
98+
* `db.system.name` - Always set to `"oracle.db"`
99+
* `error.type` - Error message that triggered VIP retry
100+
* `server.address` - VIP address being retried
101+
102+
**Opt-In VIP Debug Attributes** *(only present if sensitive data is enabled)*:
103+
* `server.port` - Server port number
104+
* `oracle.db.vip.protocol` - Connection protocol
105+
* `oracle.db.vip.failed_host` - Host that failed during VIP retry
106+
* `oracle.db.vip.service_name` - Oracle service name
107+
* `oracle.db.vip.sid` - Oracle System Identifier (SID)
108+
* `oracle.db.vip.connection_descriptor` - Full connection descriptor
109+
110+
#### Legacy Conventions
111+
When `OTEL_SEMCONV_STABILITY_OPT_IN` is empty/not set or `database/dup`:
112+
113+
* `Error message`
114+
* `VIP Address`
115+
* `Protocol` *(only present if sensitive data is enabled)*
116+
* `Host` *(only present if sensitive data is enabled)*
117+
* `Port` *(only present if sensitive data is enabled)*
118+
* `Service name` *(only present if sensitive data is enabled)*
119+
* `SID` *(only present if sensitive data is enabled)*
120+
* `Connection data` *(only present if sensitive data is enabled)*
38121

39122
## Installation
40123

@@ -69,6 +152,17 @@ oracle.jdbc.provider.traceEventListener.unique_identifier=<unique identifier>
69152

70153
If no unique identifier is provided, the unique idetifier "default" is used.
71154

155+
### Enabling Stable Semantic Conventions (OpenTelemetry)
156+
157+
To use the new stable OpenTelemetry semantic conventions, set the environment variable:
158+
```bash
159+
# Use only stable conventions
160+
export OTEL_SEMCONV_STABILITY_OPT_IN=database
161+
162+
# OR use both old and new conventions (dual mode for migration)
163+
export OTEL_SEMCONV_STABILITY_OPT_IN=database/dup
164+
```
165+
72166
## Configuration
73167

74168
The provider can be configured by:

ojdbc-provider-observability/src/main/java/oracle/jdbc/provider/observability/ObservabilityConfiguration.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,32 @@ public class ObservabilityConfiguration implements ObservabilityConfigurationMBe
108108
*/
109109
public static final String OPEN_TELEMETRY_TRACE_EVENT_LISTENER_SENSITIVE_ENABLED = "oracle.jdbc.provider.opentelemetry.sensitive-enabled";
110110

111+
/**
112+
* OpenTelemetry semantic convention stability opt-in environment variable.
113+
* Accepts a comma-separated list of values including:
114+
* "database" (new stable conventions only),
115+
* "database/dup" (both old and new conventions),
116+
* or empty/null (old conventions only)
117+
*/
118+
public static final String OTEL_SEMCONV_STABILITY_OPT_IN = "OTEL_SEMCONV_STABILITY_OPT_IN";
119+
120+
111121
/**
112122
* Default values
113123
*/
114124
private static final String DEFAULT_ENABLED_TRACERS = "OTEL,JFR";
115125
private static final String DEFAULT_SENSITIVE_DATA_ENABLED = "false";
116126
private static final String DEFAULT_OPEN_TELEMETRY_ENABLED = "true";
127+
private volatile String semconvOptIn = "";
128+
129+
public String getSemconvOptIn() {
130+
return semconvOptIn == null ? "" : semconvOptIn;
131+
}
132+
133+
public void setSemconvOptIn(String optIn) {
134+
this.semconvOptIn = optIn == null ? "" : optIn;
135+
}
136+
117137

118138
/**
119139
* Lock used to ensure that only one thread can access the configuration at a time.
@@ -173,6 +193,8 @@ public ObservabilityConfiguration() {
173193
ObservabilityConfiguration(ObservabilityConfigurationType configurationType) {
174194
String enabledTracers = DEFAULT_ENABLED_TRACERS;
175195
String sensitiveDataEnabled = DEFAULT_SENSITIVE_DATA_ENABLED;
196+
String optIn = System.getenv(OTEL_SEMCONV_STABILITY_OPT_IN);
197+
176198
if (ObservabilityConfigurationType.OBSERVABILITY.equals(configurationType)) {
177199
enabledTracers = System.getProperty(ENABLED_TRACERS, DEFAULT_ENABLED_TRACERS);
178200
sensitiveDataEnabled = System.getProperty(SENSITIVE_DATA_ENABLED, DEFAULT_SENSITIVE_DATA_ENABLED);
@@ -190,6 +212,8 @@ public ObservabilityConfiguration() {
190212

191213
setEnabledTracers(enabledTracers);
192214
setSensitiveDataEnabled(Boolean.parseBoolean(sensitiveDataEnabled));
215+
this.setSemconvOptIn(optIn);
216+
193217
}
194218

195219
/**

ojdbc-provider-observability/src/main/java/oracle/jdbc/provider/observability/ObservabilityConfigurationMBean.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@ public interface ObservabilityConfigurationMBean {
9393
* @param sensitiveDataEnabled true to enable sensitive data, otherwise false.
9494
*/
9595
void setSensitiveDataEnabled(boolean sensitiveDataEnabled);
96+
97+
String getSemconvOptIn();
98+
void setSemconvOptIn(String optIn);
99+
96100
}

0 commit comments

Comments
 (0)