Skip to content

Add OpenTelemetry metrics to Commons Pool 2 XA implementation#318

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/analyze-ojp-xa-metrics
Draft

Add OpenTelemetry metrics to Commons Pool 2 XA implementation#318
Copilot wants to merge 4 commits intomainfrom
copilot/analyze-ojp-xa-metrics

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

Exposes comprehensive pool metrics from the Apache Commons Pool 2 XA connection pool to OpenTelemetry, matching HikariCP's observability capabilities.

Metrics Exposed

Gauges: active/idle/pending connections, max/min pool size, utilization %, created/destroyed counts
Counters: pool exhaustion events, validation failures, leak detections, acquisition time/count

All metrics tagged with pool.name attribute for multi-pool environments.

Implementation

  • PoolMetrics interface - Abstraction layer for metrics collection
  • OpenTelemetryPoolMetrics - OpenTelemetry integration with 13 metrics via Meter API
  • NoOpPoolMetrics - Zero-overhead implementation when metrics disabled
  • PoolMetricsFactory - Automatic detection and instantiation based on OpenTelemetry availability
  • MetricsAwareHousekeepingListener - Wrapper to capture housekeeping events (leak detection) as metrics

Metrics update on pool operations (borrow/return/invalidate) and integrate with existing Prometheus exporter in ojp-server.

Configuration

config.put("xa.metrics.enabled", "true");      // Optional, default: auto-detect
config.put("xa.poolName", "orders-xa-pool");   // Optional, default: "ojp-xa-pool"

Design Notes

  • OpenTelemetry API is provided scope - no hard dependency
  • Automatic activation when OpenTelemetry available on classpath
  • NoOp implementation ensures zero overhead when disabled
  • Interface-based design allows future extension to other frameworks (Micrometer, etc.)

Example Prometheus output:

ojp_xa_pool_connections_active{pool_name="ojp-xa-pool"} 5.0
ojp_xa_pool_connections_idle{pool_name="ojp-xa-pool"} 15.0
ojp_xa_pool_connections_utilization{pool_name="ojp-xa-pool"} 25.0

See METRICS.md for complete reference, monitoring best practices, and alerting recommendations.

Original prompt

Do an analysis on exposing metrics from the OJP XA Apache Commons Pool 2 implementation to Open Telemetry, similarly to what HikariCP does.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 26, 2026 22:05
…tion

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze exposing metrics from OJP XA Apache Commons Pool 2 to OpenTelemetry Add OpenTelemetry metrics to Commons Pool 2 XA implementation Jan 26, 2026
Copilot AI requested a review from rrobetti January 26, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants