Skip to content

[#5575] feat(metrics):add Hive Catalog Metrics for HMS connection pool#12118

Open
yangyuxia wants to merge 1 commit into
apache:mainfrom
yangyuxia:main
Open

[#5575] feat(metrics):add Hive Catalog Metrics for HMS connection pool#12118
yangyuxia wants to merge 1 commit into
apache:mainfrom
yangyuxia:main

Conversation

@yangyuxia

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

  • ClientPoolImpl: Add currentSize() and idleCount() getters to expose pool state for monitoring.

  • CachedClientPool: Add totalCurrentSize(), totalIdleCount(), and totalPoolSize() methods that aggregate metrics across all per-user pools in the Caffeine cache.

  • MetricsProvider (new): Interface in core module that decouples HiveCatalogMetricsSource from CachedClientPool, avoiding circular dependency between core and hive-metastore-common.

  • HiveCatalogMetricsSource (new): Dropwizard CatalogMetricsSource implementation that registers three Gauges:

    • datasource.active-connections — total connections in use across all user pools
    • datasource.idle-connections — total idle connections across all user pools
    • datasource.max-connections — total configured pool capacity across all user pools
  • HiveCatalogOperations: Register HiveCatalogMetricsSource during initialize() with a MetricsProvider adapter that delegates to CachedClientPool's aggregated methods. Unregister in close().

Why are the changes needed?

Add Hive Catalog metrics for monitoring HMS (Hive Metastore) connection pool usage. This enables operators to observe the number of active, idle, and maximum connections from Gravitino to HMS via Prometheus, which is critical for capacity planning and troubleshooting connection exhaustion issues.

Fix: #5575

Does this PR introduce any user-facing change?

Yes. Users who scrape Gravitino's Prometheus endpoint will now see three new metrics per Hive Catalog:
gravitino_catalog_hive_{metalake}{catalog}datasource_active_connections
gravitino_catalog_hive
{metalake}
{catalog}datasource_idle_connections
gravitino_catalog_hive
{metalake}_{catalog}_datasource_max_connections

How was this patch tested?

Unit tests (./gradlew :core:test --tests "org.apache.gravitino.metrics.*")

@github-actions

Copy link
Copy Markdown

Code Coverage Report

Overall Project 67.7% +0.55% 🟢
Files changed 75.9% 🟢

Module Coverage
aliyun 1.72% 🔴
api 47.82% 🟢
authorization-common 85.96% 🟢
aws 42.04% 🟢
azure 2.47% 🔴
catalog-common 9.92% 🔴
catalog-fileset 79.77% +11.8% 🟢
catalog-glue 66.91% 🟢
catalog-hive 78.73% +1.72% 🟢
catalog-jdbc-common 44.81% -10.4% 🟢
catalog-jdbc-doris 81.6% +5.76% 🟢
catalog-jdbc-mysql 79.23% +12.92% 🟢
catalog-jdbc-postgresql 82.29% +10.14% 🟢
catalog-jdbc-starrocks 78.51% +6.82% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 59.18% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.87% -1.98% 🟢
catalog-lakehouse-paimon 84.25% -3.11% 🟢
catalog-model 77.72% 🟢
cli 44.5% 🟢
client-java 78.27% 🟢
common 51.95% 🟢
core 82.52% -0.29% 🟢
filesystem-hadoop3 77.28% 🟢
flink 0.0% 🔴
flink-common 47.09% 🟢
flink-runtime 0.0% 🔴
gcp 14.12% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 12.7% 🔴
hive-metastore-common 53.3% +0.57% 🟢
iceberg-common 63.77% -7.12% 🟢
iceberg-rest-server 74.9% +0.23% 🟢
idp-basic 86.02% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 20.67% 🔴
lance-rest-server 64.84% 🟢
lineage 53.02% 🟢
optimizer 83.24% 🟢
optimizer-api 21.95% 🔴
server 85.92% 🟢
server-common 76.12% 🟢
spark 28.57% 🔴
spark-common 46.01% 🟢
tencent 69.84% 🟢
trino-connector 40.29% 🟢
Files
Module File Coverage
catalog-fileset FilesetCatalogOperations.java 81.83% 🟢
catalog-hive HiveCatalogOperations.java 80.29% 🟢
catalog-jdbc-common JdbcConnectorUtils.java 100.0% 🟢
JdbcCatalogOperations.java 9.05% 🔴
catalog-jdbc-doris DorisUtils.java 95.41% 🟢
DorisTableOperations.java 83.27% 🟢
catalog-jdbc-mysql MysqlTableOperations.java 85.56% 🟢
catalog-jdbc-postgresql PostgreSqlTableOperations.java 87.43% 🟢
PostgreSqlSchemaOperations.java 78.26% 🟢
catalog-jdbc-starrocks StarRocksUtils.java 86.49% 🟢
StarRocksTableOperations.java 79.87% 🟢
catalog-lakehouse-iceberg IcebergCatalogOperations.java 78.64% 🟢
catalog-lakehouse-paimon PaimonCatalogOperations.java 71.5% 🟢
core HiveCatalogMetricsSource.java 100.0% 🟢
Configs.java 98.05% 🟢
CatalogManager.java 68.67% 🟢
ClientPoolImpl.java 65.79% 🟢
IsolatedClassLoader.java 56.6% 🔴
MetricsProvider.java 0.0% 🔴
hive-metastore-common CachedClientPool.java 75.0% 🟢
iceberg-common IcebergCatalogWrapper.java 28.86% 🔴
iceberg-rest-server CatalogWrapperForREST.java 78.43% 🟢

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.

[Improvement] Reporting the metrics of the clientPool in hive, iceberg, and paimon

1 participant