Skip to content

Commit c649e57

Browse files
committed
Refactoring and added possibility to have different configuration and listeners
1 parent dee07b4 commit c649e57

22 files changed

+1598
-828
lines changed

ojdbc-provider-observability/README.md

+14-13
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ This provider implements the TraceEventListener interface provided by the JDBC
99
driver which will be notified whenever events are generated in the driver and
1010
will publish these events into Open Telemetry. These events include:
1111
* roundtrips to the database server
12-
* AC begin and sucess
12+
* AC begin and success
1313
* VIP down event
1414

15-
The following attributes are added the the traces for each event:
15+
The following attributes are added the traces for each event:
1616
* **Roundtrips**
1717
* Connection ID
1818
* Database Operation
@@ -39,7 +39,7 @@ The following attributes are added the the traces for each event:
3939
## Installation
4040

4141
This provider is distributed as single jar on the Maven Central Repository. The
42-
jar is compiled for JDK 8, and is forward compatible with later JDK versions.
42+
jar is compiled for JDK 11, and is forward compatible with later JDK versions.
4343
The coordinates for the latest release are:
4444

4545
```xml
@@ -62,24 +62,26 @@ oracle.jdbc.provider.traceEventListener=observability-trace-event-listener-provi
6262
## Configuration
6363

6464
The provider can be configured by:
65-
* using the singleton configuration class,
66-
```java
67-
ObservabilityConfiguration.getInstance().setEnabledTracers("OTEL,JFR");
68-
ObservabilityConfiguration.getInstance().setSensitiveDataEnabled(true);
69-
```
7065
* using system properties,
7166
```java
7267
System.setProperty("oracle.jdbc.provider.observability.enabledTracers", "OTEL,JFR");
7368
System.setProperty("oracle.jdbc.provider.observability.sensitiveDataEnabled", "true");
7469
```
7570
* or using the MBean.
7671
```java
77-
ObjectName objectName = new ObjectName(
78-
"com.oracle.jdbc.provider.observability:type=ObservabilityConfiguration");
72+
ObservabilityTraceEventListener listener = ObservabilityTraceEventListener.getTraceEventListener("<name>");
73+
ObjectName objectName = new ObjectName(listener.getMBeanObjectName());
7974
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
8075
server.setAttribute(objectName, new Attribute("EnabledTracers", "OTEL,JFR"));
8176
server.setAttribute(objectName, new Attribute("SensitiveDataEnabled", "true"));
8277
```
78+
* it is also possible to use the ObservabilityConfiguration object directly by
79+
calling the
80+
```java
81+
ObservabilityConfiguration configuration = ObservabilityTraceEventListener.getObservabilityConfiguration("<name>");
82+
configuration.setEnabledTracers("OTEL,JFR");
83+
configuration.setSensitiveDataEnabled(true);
84+
```
8385

8486
## Backward compatibility
8587

@@ -109,13 +111,12 @@ or a MBean. Two parameters can be configured:
109111

110112
The system properties are "oracle.jdbc.provider.opentelemetry.enabled" and
111113
"oracle.jdbc.provider.opentelemetry.sensitive-enabled" respectively and the MBean
112-
with object name "com.oracle.jdbc.extension.opentelemetry:type=OpenTelemetryTraceEventListener"
113114
exposes two attributes "Enabled" and "SensitiveDataEnabled".
114115

115116
The sample code below shows how to retrieve the value of an attribute:
116117
```java
117-
ObjectName objectName = new ObjectName(
118-
"com.oracle.jdbc.extension.opentelemetry:type=OpenTelemetryTraceEventListener");
118+
ObservabilityTraceEventListener listener = ObservabilityTraceEventListener.getTraceEventListener("<name>");
119+
ObjectName objectName = new ObjectName(listener.getMBeanObjectName());
119120
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
120121
boolean isEnabled = Boolean.valueOf(server.getAttribute(objectName, "Enabled").toString())
121122
.booleanValue();

0 commit comments

Comments
 (0)