Skip to content

Add Micrometer metrics integration to OJP JDBC driver and Spring Boot starter#394

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/analyze-micrometer-reporting-ojp
Draft

Add Micrometer metrics integration to OJP JDBC driver and Spring Boot starter#394
Copilot wants to merge 2 commits intomainfrom
copilot/analyze-micrometer-reporting-ojp

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 19, 2026

OJP had OpenTelemetry metrics on the server side only — no client-side instrumentation and no Micrometer support for Spring Boot apps.

Driver-side metrics SPI (ojp-jdbc-driver)

Introduces a zero-coupling metrics abstraction so the driver never imports Micrometer:

  • OjpDriverMetrics — interface with hooks: onConnectionCreated/Failed/Closed, onStatementExecuted(ms), onStatementFailed
  • NoOpOjpDriverMetrics — singleton no-op default (zero overhead when no integration is active)
  • OjpDriverMetricsHoldervolatile global holder; integrations call OjpDriverMetricsHolder.set(impl) at startup
  • OjpMetricsIterator — wraps the server-streaming gRPC query iterator so timing/errors are recorded across the full result-stream lifetime, not just at RPC initiation

Hooks wired into:

Site Event
Driver.connect() onConnectionCreated / onConnectionFailed
Connection.close() onConnectionClosed
StatementServiceGrpcClient.executeUpdate() onStatementExecuted(ms) / onStatementFailed
StatementServiceGrpcClient.executeQuery() delegated to OjpMetricsIterator

Micrometer auto-configuration (spring-boot-starter-ojp)

  • OjpMicrometerDriverMetricsOjpDriverMetrics impl backed by a MeterRegistry
  • OjpMicrometerAutoConfiguration — activates only when @ConditionalOnBean(MeterRegistry.class) + OJP URL present; wires the impl into OjpDriverMetricsHolder

Activating is zero-config when spring-boot-starter-actuator is on the classpath. To disable:

@SpringBootApplication(exclude = OjpMicrometerAutoConfiguration.class)

Meters exposed

Meter Type
ojp.driver.connections.created Counter
ojp.driver.connections.failed Counter
ojp.driver.connections.closed Counter
ojp.driver.connections.active Gauge
ojp.driver.statements.executed Counter
ojp.driver.statements.failed Counter
ojp.driver.statements.execution.time Distribution Summary (ms)

All metrics auto-export to any configured Micrometer backend (Prometheus, Datadog, InfluxDB, etc.) without additional config. micrometer-core is declared optional so it does not become a transitive dependency.


💡 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.

… starter

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

Copilot AI changed the title [WIP] Analyze integration requirements for Micrometer reporting to OJP Add Micrometer metrics integration to OJP JDBC driver and Spring Boot starter Mar 19, 2026
Copilot AI requested a review from rrobetti March 19, 2026 08:39
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