diff --git a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala index ee945da2618..3db6daba4b2 100644 --- a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala +++ b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/MetricsSystem.scala @@ -58,6 +58,10 @@ class MetricsSystem extends CompositeService("MetricsSystem") { meter.mark(value) } + def getGauge[T](name: String): Option[Gauge[T]] = { + Option(registry.gauge(name)) + } + def registerGauge[T](name: String, value: => T, default: T): Unit = { registry.register( MetricRegistry.name(name), @@ -123,10 +127,6 @@ object MetricsSystem { maybeSystem.map(_.registry.meter(name).getCount) } - def getGauge(name: String): Option[Gauge[_]] = { - maybeSystem.map(_.registry.gauge(name)) - } - def histogramSnapshot(name: String): Option[Snapshot] = { maybeSystem.map(_.registry.histogram(name).getSnapshot) } diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala index 509bc4289c7..3edd82e960f 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/util/SSLUtils.scala @@ -58,8 +58,8 @@ object SSLUtils extends Logging { keyStoreType).foreach { expiration => info(s"Thrift SSL Serve KeyStore ${keyStorePath.get} will expire at:" + s" ${Utils.getDateFromTimestamp(expiration)}") - if (MetricsSystem.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) { - MetricsSystem.tracing { ms => + MetricsSystem.tracing { ms => + if (ms.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) { ms.registerGauge( MetricsConstants.THRIFT_SSL_CERT_EXPIRATION, expiration - System.currentTimeMillis(),