UCP Metrics for Oracle AI Database

UCP metrics are database-client metrics from Oracle UCP (Universal Connection Pool), Oracle’s JDBC connection pool. Like HikariCP, UCP exposes pool-specific metrics: current and maximum connections, callers waiting for a connection, acquisition time, and pool lifecycle activity.

These metrics help separate a slow query from a slow path to a query. When an application exhausts its pool, waits to acquire connections, or accumulates latency before calls reach Oracle AI Database, UCP metrics show where to investigate.

Configure and use UCP metrics

To start collecting metrics, add the oracle-spring-boot-ucp-micrometer dependency to your project. spring-boot-starter-actuator should be included to manage and scrape metrics:

<dependency>
  <groupId>cm.oracle.database.spring</groupId>
  <artifactId>oracle-spring-boot-ucp-micrometer</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Then, configure your project to export metrics via application properties. For Spring Actuator expose the /actuator/metrics endpoint:

management:
  endpoints:
    web:
      exposure:
        include: metrics

For push-based collection, configure Spring Boot’s OTLP metrics exporter:

management:
  otlp:
    metrics:
      export:
        enabled: true
        url: http://your-otel-endpoint:4318/v1/metrics
        step: 5s

Try it out with our UCP Spring Boot sample

If you’d like to experiment with metrics using Oracle AI Database Free, I built an all-in-one Docker Compose sample that spins up Oracle AI Database, a Spring Boot app, and Grafana LGTM for testing.

To test the sample, check out the code here and run:

export ORACLE_PWD="${ORACLE_PWD:-Welcome12345}"
docker compose up --build -d

Then, check out the Grafana dashboard at http://localhost:3000.

A sample load-generator script is provided to utilize the connection pool.

Terminal output showing Oracle database logs and Spring application metrics.
Spinning up the Docker Compose environment with Oracle AI Database Free

Sample Grafana Dashboard

To help you visualize statistics from UCP, I built a sample Grafana dashboard that uses these metrics. You can adopt this dashboard out of the box, or use it as a starting point for customization.

The dashboard includes information about the selected connection pool, like active connections, utilization rate, latency:

Dashboard displaying database connection metrics including used and idle connections, pool utilization, pending requests, connections by state, borrow and return rates, pool capacity, and connection acquire time.
Grafana dashboard visualizing a given connection pool

What kind of UCP metrics are collected?

OpenTelemetry database client metrics are exposed under the db.client namespace with the db.client.connection.pool.name attribute set to the configured spring.datasource.oracleucp.connection-pool-name. Otherwise, he Spring DataSource bean name is used as the pool name.

MetricDescriptionKey attributes
db.client.connection.countConnections currently available (idle) or borrowed (used)db.client.connection.pool.name, db.client.connection.state
db.client.connection.maxConfigured upper limit for open connectionsdb.client.connection.pool.name
db.client.connection.idle.minConfigured minimum idle connections, when the UCP version supports itdb.client.connection.pool.name
db.client.connection.pending_requestsRequests currently waiting for a connectiondb.client.connection.pool.name

The module also includes UCP-specific metrics under the ucp.connections namespace, which describe the connection pool in detail:

GroupExamplesWhat it’s for
Capacity and inventoryucp.connections, .min, .capacity, .peakTotal, minimum, remaining, and peak connections
Utilization.active.average, .active.peak, .labeled, .abandonedBorrowed connection levels, labels, and reclaimed abandoned connections
Lifecycle.created, .closed, .borrowed, .returned, .creation.attemptsPool creation, closure, and borrow/return activity
Acquisition.acquire.average, .acquire.peak, .acquire, .acquire.failed, .acquire.totalTypical, worst-case, successful, failed, and combined acquisition time
Usage.usageTime connections spend in use

References

Leave a Reply