Skip to content

Commit

Permalink
prevent conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Dec 26, 2024
1 parent 982f175 commit fe48b66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit fe48b66

Please sign in to comment.