Skip to content

Reduce cardinality of default Tomcat JDBC pool names#19173

Open
YaoYingLong wants to merge 3 commits into
open-telemetry:mainfrom
YaoYingLong:feature/tomcat-jdbc
Open

Reduce cardinality of default Tomcat JDBC pool names#19173
YaoYingLong wants to merge 3 commits into
open-telemetry:mainfrom
YaoYingLong:feature/tomcat-jdbc

Conversation

@YaoYingLong

@YaoYingLong YaoYingLong commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description

Tomcat JDBC generates default pool names in this format:

Tomcat Connection Pool[<counter>-<PoolProperties identity hash>]

The identity hash makes the pool.name / db.client.connection.pool.name
metric attribute unstable across JVM instances and can create unnecessary
time-series cardinality.

This change:

  • detects Tomcat-generated default pool names and unnamed pools;
  • derives a stable pool name from the JDBC URL and connection properties as
    server.address[:server.port][/db.namespace];
  • preserves explicitly configured pool names;
  • falls back to tomcat-jdbc when no server address or database namespace can
    be derived;
  • intentionally allows pools targeting the same database to share a metric
    attribute value, which is aggregated by asynchronous metric observation.

Only automatically generated or unnamed pool names are affected. Explicit pool
names continue to be reported unchanged.

Compatibility

The implementation uses DataSourceProxy#getPoolProperties() together with
PoolConfiguration#getUrl() and PoolConfiguration#getDbProperties(). These
APIs are available across the supported Tomcat JDBC versions.

Copilot AI review requested due to automatic review settings July 10, 2026 04:02
@YaoYingLong
YaoYingLong requested a review from a team as a code owner July 10, 2026 04:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces metric cardinality by normalizing Tomcat-generated JDBC pool names while retaining configured names.

Changes:

  • Maps generated names to process-local jdbc-<id> values.
  • Tests multiple pools, configured names, and repeated lifecycle calls.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
TomcatConnectionPoolMetrics.java Detects and normalizes generated pool names.
TomcatJdbcInstrumentationTest.java Verifies naming and lifecycle behavior.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 10, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-22 03:19:14 UTC.

  • Waiting on: Reviewers
  • Next step: Review the latest changes.

This automated status or its linked feedback items may be incorrect. If something looks wrong, report it with the result you expected.

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.

3 participants