Keep a strong reference to expiration in Gauge
This commit is contained in:
parent
ffa98e5b34
commit
37038c4a63
|
@ -8,8 +8,8 @@ package org.whispersystems.textsecuregcm.metrics;
|
||||||
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
|
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import io.micrometer.core.instrument.Gauge;
|
||||||
import io.micrometer.core.instrument.Metrics;
|
import io.micrometer.core.instrument.Metrics;
|
||||||
import io.micrometer.core.instrument.Tags;
|
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
import java.security.cert.Certificate;
|
import java.security.cert.Certificate;
|
||||||
|
@ -45,10 +45,13 @@ public class TlsCertificateExpirationUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
getIdentifiersAndExpirations(keyStore, keyStorePassword)
|
getIdentifiersAndExpirations(keyStore, keyStorePassword)
|
||||||
.forEach((id, expiration) -> {
|
.forEach((id, expiration) ->
|
||||||
Metrics.gauge(CERTIFICATE_EXPIRATION_GAUGE_NAME,
|
Gauge.builder(CERTIFICATE_EXPIRATION_GAUGE_NAME, expiration,
|
||||||
Tags.of("id", id), expiration, then -> Duration.between(Instant.now(), then).toSeconds());
|
then -> Duration.between(Instant.now(), then).toSeconds())
|
||||||
});
|
.tags("id", id)
|
||||||
|
.strongReference(true)
|
||||||
|
.register(Metrics.globalRegistry)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
Loading…
Reference in New Issue