mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-11-30 01:06:50 +00:00
Add timer to measure warmup time
This commit is contained in:
1 parent
93ade07c57
commit
4d48c40ce1
1 file changed
+7
+7
@@ -5,8 +5,11 @@ import io.dropwizard.lifecycle.Managed;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Timer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||
|
||||
public class FoundationDBWarmup implements Managed {
|
||||
|
||||
@@ -17,6 +20,8 @@ public class FoundationDBWarmup implements Managed {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FoundationDBWarmup.class);
|
||||
|
||||
private static final Timer WARMUP_TIMER = Metrics.timer(MetricsUtil.name(FoundationDBWarmup.class, "warmupTimer"));
|
||||
|
||||
private static final byte[] STATUS_JSON_KEY;
|
||||
|
||||
static {
|
||||
@@ -43,9 +48,11 @@ public class FoundationDBWarmup implements Managed {
|
||||
/// @param database the FoundationDB [Database] instance
|
||||
private void readStatusKey(final String databaseName, final Database database) {
|
||||
int attempts = 0;
|
||||
final Timer.Sample sample = Timer.start();
|
||||
while (true) {
|
||||
try {
|
||||
database.readAsync(transaction -> transaction.get(STATUS_JSON_KEY)).join();
|
||||
sample.stop(WARMUP_TIMER);
|
||||
return;
|
||||
} catch (final Exception e) {
|
||||
attempts++;
|
||||
|
||||
Reference in new issue
Block a user