Skip to content

Commit 5e4d39d

Browse files
fix: Rename gauge to db.pool.connections to avoid Prometheus _total suffix
The new Prometheus Java client (used by PrometheusMeterRegistry in micrometer 1.14.5) strips the _total suffix from metric names because it is reserved for counters. The gauge db.connections.total was being sanitized to db_connections, causing the test to fail when looking for db_connections_total in the scrape output. Renamed to db.pool.connections which exports as db_pool_connections in Prometheus format, avoiding suffix conflicts.
1 parent eff7b3f commit 5e4d39d

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

openmetadata-service/src/main/java/org/openmetadata/service/monitoring/OpenMetadataMetrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public OpenMetadataMetrics(MeterRegistry meterRegistry) {
5050
.sla(LATENCY_SLA_BUCKETS)
5151
.register(meterRegistry);
5252

53-
Gauge.builder("db.connections.total", () -> poolTotalConnections())
53+
Gauge.builder("db.pool.connections", () -> poolTotalConnections())
5454
.description("Total connections in the database connection pool")
5555
.register(meterRegistry);
5656

openmetadata-service/src/test/java/org/openmetadata/service/monitoring/OpenMetadataMetricsTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ void dbConnectionsTotalReflectsHikariCPPoolSize() {
3333

3434
new OpenMetadataMetrics(registry);
3535

36-
Gauge total = registry.find("db.connections.total").gauge();
37-
assertNotNull(total, "db.connections.total gauge should be registered");
36+
Gauge total = registry.find("db.pool.connections").gauge();
37+
assertNotNull(total, "db.pool.connections gauge should be registered");
3838
assertEquals(20.0, total.value(), 0.01, "Should equal active + idle");
3939

4040
activeConnections.set(10);
@@ -50,8 +50,8 @@ void dbConnectionsTotalReflectsHikariCPPoolSize() {
5050
void dbConnectionsTotalReturnsZeroWithoutHikariCP() {
5151
new OpenMetadataMetrics(registry);
5252

53-
Gauge total = registry.find("db.connections.total").gauge();
54-
assertNotNull(total, "db.connections.total gauge should be registered");
53+
Gauge total = registry.find("db.pool.connections").gauge();
54+
assertNotNull(total, "db.pool.connections gauge should be registered");
5555
assertEquals(0.0, total.value(), 0.01, "Should be zero when HikariCP metrics are absent");
5656
}
5757

@@ -71,10 +71,10 @@ void prometheusScrapeExposesDbConnectionsTotal() {
7171

7272
String scrape = promRegistry.scrape();
7373
assertTrue(
74-
scrape.contains("db_connections_total"),
75-
"Prometheus scrape should contain db_connections_total metric");
74+
scrape.contains("db_pool_connections"),
75+
"Prometheus scrape should contain db_pool_connections metric");
7676
assertTrue(
77-
scrape.contains("# TYPE db_connections_total gauge"),
78-
"db_connections_total should be exposed as a gauge type");
77+
scrape.contains("# TYPE db_pool_connections gauge"),
78+
"db_pool_connections should be exposed as a gauge type");
7979
}
8080
}

0 commit comments

Comments
 (0)