Skip to content

Commit

Permalink
[KYUUBI #6866][FOLLOWUP] Prevent register gauge conflicts if both thr…
Browse files Browse the repository at this point in the history
…ift binary SSL and thrift http SSL enabled

### Why are the changes needed?

Followup for #6866
It would throw exception if both thrift binary SSL and thrift http SSL enabled

### How was this patch tested?

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #6872 from turboFei/duplicate_gauge.

Closes #6866

ea35676 [Wang, Fei] prevent conflicts
982f175 [Wang, Fei] conflicts

Authored-by: Wang, Fei <[email protected]>
Signed-off-by: Wang, Fei <[email protected]>
  • Loading branch information
turboFei committed Dec 27, 2024
1 parent 8742334 commit 164df8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ object SSLUtils extends Logging {
keyStorePath.get,
keyStorePassword.get,
keyStoreType).foreach { expiration =>
info(s"Thrift SSL Serve KeyStore ${keyStorePath.get} will expire at:" +
info(s"Thrift SSL Server KeyStore ${keyStorePath.get} will expire at:" +
s" ${Utils.getDateFromTimestamp(expiration)}")
MetricsSystem.tracing { ms =>
ms.registerGauge(
MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
expiration - System.currentTimeMillis(),
0L)
if (ms.getGauge(MetricsConstants.THRIFT_SSL_CERT_EXPIRATION).isEmpty) {
ms.registerGauge(
MetricsConstants.THRIFT_SSL_CERT_EXPIRATION,
expiration - System.currentTimeMillis(),
0L)
}
}
}
}
Expand Down

0 comments on commit 164df8d

Please sign in to comment.