Skip to content

Commit 7f305d3

Browse files
implementing JFR and Open telemetry providers to monitor UCP
1 parent 59f3262 commit 7f305d3

28 files changed

+1819
-64
lines changed
Lines changed: 117 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,127 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
66

7-
<parent>
7+
<parent>
88
<groupId>com.oracle.database.jdbc</groupId>
99
<artifactId>ojdbc-extensions</artifactId>
1010
<version>1.0.3</version>
11-
</parent>
11+
</parent>
1212

13-
<name>Oracle JDBC Observability Provider</name>
14-
<groupId>com.oracle.database.jdbc</groupId>
15-
<artifactId>ojdbc-provider-observability</artifactId>
13+
<name>Oracle JDBC Observability Provider</name>
14+
<groupId>com.oracle.database.jdbc</groupId>
15+
<artifactId>ojdbc-provider-observability</artifactId>
1616

17-
<properties>
18-
<opentelemetry.version>1.44.1</opentelemetry.version>
19-
<maven.compiler.source>11</maven.compiler.source>
20-
<maven.compiler.target>11</maven.compiler.target>
21-
</properties>
17+
<properties>
18+
<opentelemetry.version>1.44.1</opentelemetry.version>
19+
<maven.compiler.source>11</maven.compiler.source>
20+
<maven.compiler.target>11</maven.compiler.target>
21+
</properties>
2222

23-
<dependencies>
24-
<dependency>
25-
<groupId>com.oracle.database.jdbc</groupId>
26-
<artifactId>ojdbc11</artifactId>
27-
</dependency>
28-
<dependency>
29-
<groupId>io.opentelemetry</groupId>
30-
<artifactId>opentelemetry-api</artifactId>
31-
<version>${opentelemetry.version}</version>
32-
</dependency>
33-
<dependency>
34-
<groupId>org.mockito</groupId>
35-
<artifactId>mockito-core</artifactId>
36-
<scope>test</scope>
37-
</dependency>
38-
<dependency>
39-
<groupId>org.junit.jupiter</groupId>
40-
<artifactId>junit-jupiter-engine</artifactId>
41-
<scope>test</scope>
42-
</dependency>
43-
<dependency>
44-
<groupId>org.junit.jupiter</groupId>
45-
<artifactId>junit-jupiter-params</artifactId>
46-
<scope>test</scope>
47-
</dependency>
48-
<dependency>
49-
<artifactId>ojdbc-provider-common</artifactId>
50-
<groupId>com.oracle.database.jdbc</groupId>
51-
<classifier>tests</classifier>
52-
<type>test-jar</type>
53-
</dependency>
54-
</dependencies>
55-
<build>
56-
<plugins>
57-
<plugin>
58-
<groupId>org.apache.maven.plugins</groupId>
59-
<artifactId>maven-surefire-plugin</artifactId>
60-
<configuration>
61-
<!--
62-
ObservabilityConfigurationTest must run first and alone since it depends on
63-
ObservabilityConfiguration being started with system properties set on the
64-
test.
65-
Running tests alphabetical and single threaded ensures that.
66-
-->
67-
<parallel>none</parallel>
68-
<runOrder>alphabetical</runOrder>
69-
</configuration>
70-
</plugin>
71-
</plugins>
72-
</build>
23+
<dependencies>
24+
<!--<dependency>
25+
<groupId>com.oracle.database.jdbc</groupId>
26+
<artifactId>ojdbc11</artifactId>
27+
</dependency>-->
28+
<dependency>
29+
<groupId>com.oracle</groupId>
30+
<artifactId>ojdbc</artifactId>
31+
<version>11.2.0.4</version> <!-- Change to your version -->
32+
<scope>system</scope>
33+
<systemPath>/Users/abdessamadelaaissaoui/Desktop/jars/ojdbc21.jar</systemPath>
34+
</dependency>
35+
<dependency>
36+
<groupId>io.opentelemetry</groupId>
37+
<artifactId>opentelemetry-api</artifactId>
38+
<version>${opentelemetry.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.mockito</groupId>
42+
<artifactId>mockito-core</artifactId>
43+
<scope>test</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.junit.jupiter</groupId>
47+
<artifactId>junit-jupiter-engine</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.junit.jupiter</groupId>
52+
<artifactId>junit-jupiter-params</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<artifactId>ojdbc-provider-common</artifactId>
57+
<groupId>com.oracle.database.jdbc</groupId>
58+
<classifier>tests</classifier>
59+
<type>test-jar</type>
60+
</dependency>
61+
<dependency>
62+
<groupId>com.oracle</groupId>
63+
<artifactId>ucp</artifactId>
64+
<version>11.2.0.4</version> <!-- Change to your version -->
65+
<scope>system</scope>
66+
<systemPath>/Users/abdessamadelaaissaoui/Desktop/jars/ucp21.jar</systemPath>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>com.oracle</groupId>
71+
<artifactId>oraclepki</artifactId>
72+
<version>1.0</version>
73+
<scope>system</scope>
74+
<systemPath>/Users/abdessamadelaaissaoui/Downloads/oraclepki.jar</systemPath>
75+
</dependency>
76+
<dependency>
77+
<groupId>com.oracle</groupId>
78+
<artifactId>ons</artifactId>
79+
<version>1.0</version>
80+
<scope>system</scope>
81+
<systemPath>/Users/abdessamadelaaissaoui/Downloads/ons.jar</systemPath>
82+
</dependency>
83+
<!-- OpenTelemetry API -->
84+
<dependency>
85+
<groupId>io.opentelemetry</groupId>
86+
<artifactId>opentelemetry-api</artifactId>
87+
<version>1.32.0</version>
88+
</dependency>
89+
90+
<!-- OpenTelemetry SDK -->
91+
<dependency>
92+
<groupId>io.opentelemetry</groupId>
93+
<artifactId>opentelemetry-sdk</artifactId>
94+
<version>1.32.0</version>
95+
</dependency>
96+
97+
<!-- Prometheus Exporter -->
98+
<dependency>
99+
<groupId>io.opentelemetry</groupId>
100+
<artifactId>opentelemetry-exporter-prometheus</artifactId>
101+
<version>1.32.0-alpha</version>
102+
</dependency>
103+
<dependency>
104+
<groupId>io.opentelemetry</groupId>
105+
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
106+
<version>1.32.0</version>
107+
</dependency>
108+
</dependencies>
109+
<build>
110+
<plugins>
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-surefire-plugin</artifactId>
114+
<configuration>
115+
<!--
116+
ObservabilityConfigurationTest must run first and alone since it depends on
117+
ObservabilityConfiguration being started with system properties set on the
118+
test.
119+
Running tests alphabetical and single threaded ensures that.
120+
-->
121+
<parallel>none</parallel>
122+
<runOrder>alphabetical</runOrder>
123+
</configuration>
124+
</plugin>
125+
</plugins>
126+
</build>
73127
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Global configuration
2+
global:
3+
scrape_interval: 15s # Scrape targets every 15 seconds
4+
evaluation_interval: 15s # Evaluate rules every 15 seconds
5+
6+
# Scrape configuration
7+
scrape_configs:
8+
# Job to scrape your UCP application
9+
- job_name: 'ucp-application'
10+
static_configs:
11+
- targets: ['localhost:8080'] # Your app's metrics endpoint
12+
scrape_interval: 5s # Scrape every 5 seconds for testing
13+
metrics_path: '/metrics' # Path to metrics endpoint
14+
15+
# Job to scrape Prometheus itself (optional)
16+
- job_name: 'prometheus'
17+
static_configs:
18+
- targets: ['localhost:9091'] # ✅ Changed from 9090 to 9091
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package oracle.ucp.provider.observability.jfr.core;
2+
3+
import oracle.ucp.events.core.UCPEventContext;
4+
import oracle.ucp.events.core.UCPEventListener;
5+
import oracle.ucp.events.core.UCPEventListenerProvider;
6+
7+
import java.util.Map;
8+
9+
/**
10+
* A {@link UCPEventListenerProvider} implementation that records UCP events as
11+
* Java Flight Recorder (JFR) events for advanced monitoring and diagnostics.
12+
*
13+
* <p><b>Key Features:</b></p>
14+
* <ul>
15+
* <li>Integrates with Java Flight Recorder for low-overhead event recording</li>
16+
* <li>Captures complete event context as JFR event attributes</li>
17+
* <li>Thread-safe singleton listener instance</li>
18+
* <li>Registered name: "jfr-ucp-listener"</li>
19+
* </ul>
20+
*
21+
* <p><b>Prerequisites:</b></p>
22+
* <ul>
23+
* <li>JFR must be enabled on the JVM (-XX:StartFlightRecording)</li>
24+
* <li>Requires JDK 7u4+ (with JFR support)</li>
25+
* </ul>
26+
*
27+
* @see UCPEventFactory
28+
* @see jdk.jfr.Event
29+
*/
30+
public final class JFRUCPEventListenerProvider implements
31+
UCPEventListenerProvider {
32+
33+
private final UCPEventListener listener;
34+
35+
/**
36+
* The singleton event listener instance that records events via JFR.
37+
* <p><b>Characteristics:</b>
38+
* <ul>
39+
* <li>Records events with full context as JFR events</li>
40+
* <li>Adds all pool metrics as event attributes</li>
41+
* <li>Extremely low overhead (JFR-optimized)</li>
42+
* <li>Thread-safe for concurrent event recording</li>
43+
* </ul>
44+
*/
45+
public static final UCPEventListener TRACE_EVENT_LISTENER =
46+
new UCPEventListener() {
47+
@Override
48+
public void onUCPEvent(EventType eventType, UCPEventContext context) {
49+
UCPEventFactory.recordEvent(eventType, context);
50+
}
51+
};
52+
53+
/**
54+
* Creates a new provider instance that will supply
55+
* the {@link #TRACE_EVENT_LISTENER}.
56+
*/
57+
public JFRUCPEventListenerProvider() {
58+
this.listener = TRACE_EVENT_LISTENER;
59+
}
60+
61+
/**
62+
* Returns the provider's unique name "jfr-ucp-listener".
63+
*
64+
* @return The constant provider name
65+
*/
66+
@Override
67+
public String getName() {
68+
return "jfr-ucp-listener";
69+
}
70+
71+
/**
72+
* Returns the JFR recording listener instance, ignoring any configuration.
73+
*
74+
* @param config Configuration map (ignored by this implementation)
75+
* @return The {@link #TRACE_EVENT_LISTENER} instance
76+
*/
77+
@Override
78+
public UCPEventListener getListener(Map<String, String> config) {
79+
return listener;
80+
}
81+
}

0 commit comments

Comments
 (0)