Repository navigation
[Server] Report database connection pool usage in /metrics - #2284
Conversation
|
/review |
|
@shba24 please take a look |
| + " 0.0", | ||
| "http_server_requests_total"); | ||
| "http_server_requests_total", | ||
| "hikaricp_connections_active", |
There was a problem hiding this comment.
Nit (not a blocker): Pool metric assertions only check name substrings, not series or values
The new assertions at lines 220-221 look for the substrings hikaricp_connections_active and hikaricp_connections_max in the /metrics body. A substring can also match the # HELP or # TYPE lines, so it says nothing about whether a sample with a value exists. The idle, pending and bare hikaricp_connections gauges are not asserted at all. The gauges look correct at head. This only makes the test stricter about what monitoring would rely on.
For example: If hikaricp_connections_pending were dropped from bindHikariPool, or a gauge reported NaN, this test would still pass. The # TYPE hikaricp_connections_active gauge line alone satisfies the substring check.
List<String> poolSamples =
response.body().lines().filter(line -> line.startsWith("hikaricp_connections")).toList();
for (String name :
List.of(
"hikaricp_connections_active",
"hikaricp_connections_idle",
"hikaricp_connections_pending",
"hikaricp_connections",
"hikaricp_connections_max")) {
assertThat(poolSamples)
.anyMatch(line -> line.startsWith(name + "{pool=") && !line.endsWith(" NaN"));
}
assertThat(poolSamples)
.anyMatch(line -> line.startsWith("hikaricp_connections_max{") && !line.endsWith(" 0.0"));
How about checking the sample lines for all five series in the existing helper, so the test covers real values and not only names?
There was a problem hiding this comment.
Good catch, thanks! The test now checks a sample line with a value for all five series, and that hikaricp_connections_max is not zero. Also rebased on main to resolve the conflict with #2266.
Signed-off-by: Sakshi Bhasin <[email protected]>
290eb2b to
6d5443c
Compare
| | `uc_securable_table_creations_total` | Table securables created after their database transactions commit through UC, Delta, or Iceberg REST, including tables, views, and metric views | | ||
| | `uc_storage_credential_cache_requests_total` | Credential requests to the [storage credential cache](configuration.md#storage-credential-cache), tagged by `result`: `hit` for a credential served from the cache, `miss` for a request the cache could not serve, which vends a new credential; a vend that fails also counts as a miss. Both series are exposed from startup and stay at zero while the cache is disabled | | ||
| | `uc_storage_cleanup_attempts_total` | Attempts by the storage cleanup worker to delete a dropped managed resource's files, tagged by `result` and `resource_type`. `success` means the attempt deleted the files; `failure` means the attempt failed, either deleting the files or saving the result to the database, and the task will be retried. It counts attempts, not dropped resources: when a lease expires and another attempt runs, one resource can record more than one success. `resource_type` is `table`, `volume`, `registered_model`, `model_version`, or `staging_table`. Every series is exposed from startup | | ||
| | `hikaricp_connections_active`, `hikaricp_connections_idle`, `hikaricp_connections_pending`, `hikaricp_connections`, `hikaricp_connections_max` | Usage of the database connection pool, tagged by `pool`: connections in use, idle connections, threads waiting for a connection, total connections, and the pool's maximum size. When `pending` stays above zero, requests are waiting for a free connection | |
There was a problem hiding this comment.
Nit (not a blocker): Docs say requests are waiting, but pending counts every waiting thread
The hikaricp_connections_pending gauge reads HikariPoolMXBean.getThreadsAwaitingConnection, which counts any thread waiting on the pool. The same pool also serves the readiness checker (its own db-readiness-checker thread) and the storage cleanup worker, so pending can be above zero when no API request is waiting.
For example: The readiness probe waits for a connection while the pool is full and no API call is in flight. pending is 1, and the doc tells the operator that requests are waiting.
| | `hikaricp_connections_active`, `hikaricp_connections_idle`, `hikaricp_connections_pending`, `hikaricp_connections`, `hikaricp_connections_max` | Usage of the database connection pool, tagged by `pool`: connections in use, idle connections, threads waiting for a connection, total connections, and the pool's maximum size. When `pending` stays above zero, requests are waiting for a free connection | | |
| | `hikaricp_connections_active`, `hikaricp_connections_idle`, `hikaricp_connections_pending`, `hikaricp_connections`, `hikaricp_connections_max` | Usage of the database connection pool, tagged by `pool`: connections in use, idle connections, threads waiting for a connection, total connections, and the pool's maximum size. When `pending` stays above zero, threads are waiting for a free connection; these can be API requests or background tasks such as the readiness check and the storage cleanup worker | |
How about wording the last sentence in terms of threads, so it matches what the gauge counts?
|
/review |
yili-db
left a comment
There was a problem hiding this comment.
[AI Assisted] Approving at 6d5443c. The pool gauges, their names and the pool tag match HikariCP's own Micrometer names, and a live scrape shows all five series with pool="unity-catalog". The open points are wording only, not blocking: the docs row should give the default pool name and say what pending counts, and the Javadoc should state the started-pool precondition.
No conflicts. Brings in ownership transfer (unitycatalog#2149), pool metrics (unitycatalog#2284) and the check that tests leave the checkout clean (unitycatalog#2334). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
PR Checklist
docsis updatedDescription of changes
Closes #2257
When observability is on,
/metricsnow reports the HikariCP pool with HikariCP's standard metric names, tagged bypool:hikaricp_connections_activehikaricp_connections_idlehikaricp_connections_pendinghikaricp_connectionshikaricp_connections_maxChanges:
MetricsRegistries.bindHikariPoolregisters the five gauges from the pool'sHikariPoolMXBeanandgetMaximumPoolSize(). It uses gauges and notHikariDataSource.setMetricRegistry, since a pool accepts a registry only once and tests can start more than one server on the same pool.UnityCatalogServer.initializeObservabilitycalls it right after the registry is created.docs/server/observability.md.ObservabilityEndpointsIntegrationTestnow checks forhikaricp_connections_activeandhikaricp_connections_maxin the scrape.Testing
build/sbt "server/testOnly io.unitycatalog.server.observability.ObservabilityEndpointsIntegrationTest io.unitycatalog.server.UnityCatalogServerTest"passes (10 tests).--obs-port 8090. The scrape shows all five series, for examplehikaricp_connections_max{pool="unity-catalog"} 20.0andhikaricp_connections_idle{pool="unity-catalog"} 2.0.