Configure metrics registries earlier in background command setup
This commit is contained in:
parent
d018efe2a5
commit
60814d1ff0
|
@ -15,7 +15,6 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
|
||||||
import org.whispersystems.textsecuregcm.storage.Account;
|
import org.whispersystems.textsecuregcm.storage.Account;
|
||||||
import org.whispersystems.textsecuregcm.util.logging.UncaughtExceptionHandler;
|
import org.whispersystems.textsecuregcm.util.logging.UncaughtExceptionHandler;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
@ -67,9 +66,6 @@ public abstract class AbstractSinglePassCrawlAccountsCommand extends Environment
|
||||||
this.namespace = namespace;
|
this.namespace = namespace;
|
||||||
this.commandDependencies = CommandDependencies.build(getName(), environment, configuration);
|
this.commandDependencies = CommandDependencies.build(getName(), environment, configuration);
|
||||||
|
|
||||||
MetricsUtil.configureRegistries(configuration, environment, commandDependencies.dynamicConfigurationManager());
|
|
||||||
|
|
||||||
|
|
||||||
final int segments = Objects.requireNonNull(namespace.getInt(SEGMENT_COUNT));
|
final int segments = Objects.requireNonNull(namespace.getInt(SEGMENT_COUNT));
|
||||||
|
|
||||||
logger.info("Crawling accounts with {} segments and {} processors",
|
logger.info("Crawling accounts with {} segments and {} processors",
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfigurati
|
||||||
import org.whispersystems.textsecuregcm.controllers.SecureStorageController;
|
import org.whispersystems.textsecuregcm.controllers.SecureStorageController;
|
||||||
import org.whispersystems.textsecuregcm.controllers.SecureValueRecovery2Controller;
|
import org.whispersystems.textsecuregcm.controllers.SecureValueRecovery2Controller;
|
||||||
import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
|
import org.whispersystems.textsecuregcm.experiment.ExperimentEnrollmentManager;
|
||||||
|
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||||
import org.whispersystems.textsecuregcm.push.ClientPresenceManager;
|
import org.whispersystems.textsecuregcm.push.ClientPresenceManager;
|
||||||
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
import org.whispersystems.textsecuregcm.redis.FaultTolerantRedisCluster;
|
||||||
import org.whispersystems.textsecuregcm.securestorage.SecureStorageClient;
|
import org.whispersystems.textsecuregcm.securestorage.SecureStorageClient;
|
||||||
|
@ -71,6 +72,13 @@ record CommandDependencies(
|
||||||
|
|
||||||
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
environment.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
|
||||||
|
DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager = new DynamicConfigurationManager<>(
|
||||||
|
configuration.getAppConfig().getApplication(), configuration.getAppConfig().getEnvironment(),
|
||||||
|
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
||||||
|
dynamicConfigurationManager.start();
|
||||||
|
|
||||||
|
MetricsUtil.configureRegistries(configuration, environment, dynamicConfigurationManager);
|
||||||
|
|
||||||
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
ClientResources redisClusterClientResources = ClientResources.builder().build();
|
||||||
|
|
||||||
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
FaultTolerantRedisCluster cacheCluster = new FaultTolerantRedisCluster("main_cache_cluster",
|
||||||
|
@ -103,11 +111,6 @@ record CommandDependencies(
|
||||||
ExternalServiceCredentialsGenerator secureValueRecoveryCredentialsGenerator = SecureValueRecovery2Controller.credentialsGenerator(
|
ExternalServiceCredentialsGenerator secureValueRecoveryCredentialsGenerator = SecureValueRecovery2Controller.credentialsGenerator(
|
||||||
configuration.getSvr2Configuration());
|
configuration.getSvr2Configuration());
|
||||||
|
|
||||||
DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager = new DynamicConfigurationManager<>(
|
|
||||||
configuration.getAppConfig().getApplication(), configuration.getAppConfig().getEnvironment(),
|
|
||||||
configuration.getAppConfig().getConfigurationName(), DynamicConfiguration.class);
|
|
||||||
dynamicConfigurationManager.start();
|
|
||||||
|
|
||||||
ExperimentEnrollmentManager experimentEnrollmentManager = new ExperimentEnrollmentManager(
|
ExperimentEnrollmentManager experimentEnrollmentManager = new ExperimentEnrollmentManager(
|
||||||
dynamicConfigurationManager);
|
dynamicConfigurationManager);
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,12 @@ import io.dropwizard.core.Application;
|
||||||
import io.dropwizard.core.cli.ServerCommand;
|
import io.dropwizard.core.cli.ServerCommand;
|
||||||
import io.dropwizard.core.server.DefaultServerFactory;
|
import io.dropwizard.core.server.DefaultServerFactory;
|
||||||
import io.dropwizard.core.setup.Environment;
|
import io.dropwizard.core.setup.Environment;
|
||||||
import java.time.Duration;
|
|
||||||
import io.dropwizard.jetty.HttpsConnectorFactory;
|
import io.dropwizard.jetty.HttpsConnectorFactory;
|
||||||
|
import java.time.Duration;
|
||||||
import net.sourceforge.argparse4j.inf.Namespace;
|
import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
import net.sourceforge.argparse4j.inf.Subparser;
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
import org.whispersystems.textsecuregcm.WhisperServerConfiguration;
|
||||||
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
|
|
||||||
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||||
import org.whispersystems.textsecuregcm.storage.DynamicConfigurationManager;
|
|
||||||
import org.whispersystems.textsecuregcm.storage.MessagePersister;
|
import org.whispersystems.textsecuregcm.storage.MessagePersister;
|
||||||
import org.whispersystems.textsecuregcm.util.logging.UncaughtExceptionHandler;
|
import org.whispersystems.textsecuregcm.util.logging.UncaughtExceptionHandler;
|
||||||
|
|
||||||
|
@ -52,8 +50,6 @@ public class MessagePersisterServiceCommand extends ServerCommand<WhisperServerC
|
||||||
|
|
||||||
final CommandDependencies deps = CommandDependencies.build("message-persister-service", environment, configuration);
|
final CommandDependencies deps = CommandDependencies.build("message-persister-service", environment, configuration);
|
||||||
|
|
||||||
MetricsUtil.configureRegistries(configuration, environment, deps.dynamicConfigurationManager());
|
|
||||||
|
|
||||||
if (configuration.getServerFactory() instanceof DefaultServerFactory defaultServerFactory) {
|
if (configuration.getServerFactory() instanceof DefaultServerFactory defaultServerFactory) {
|
||||||
defaultServerFactory.getApplicationConnectors()
|
defaultServerFactory.getApplicationConnectors()
|
||||||
.forEach(connectorFactory -> {
|
.forEach(connectorFactory -> {
|
||||||
|
@ -63,20 +59,11 @@ public class MessagePersisterServiceCommand extends ServerCommand<WhisperServerC
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final DynamicConfigurationManager<DynamicConfiguration> dynamicConfigurationManager = new DynamicConfigurationManager<>(
|
|
||||||
configuration.getAppConfig().getApplication(),
|
|
||||||
configuration.getAppConfig().getEnvironment(),
|
|
||||||
configuration.getAppConfig().getConfigurationName(),
|
|
||||||
DynamicConfiguration.class);
|
|
||||||
|
|
||||||
dynamicConfigurationManager.start();
|
|
||||||
|
|
||||||
final MessagePersister messagePersister = new MessagePersister(deps.messagesCache(), deps.messagesManager(),
|
final MessagePersister messagePersister = new MessagePersister(deps.messagesCache(), deps.messagesManager(),
|
||||||
deps.accountsManager(),
|
deps.accountsManager(),
|
||||||
deps.clientPresenceManager(),
|
deps.clientPresenceManager(),
|
||||||
deps.keysManager(),
|
deps.keysManager(),
|
||||||
dynamicConfigurationManager,
|
deps.dynamicConfigurationManager(),
|
||||||
Duration.ofMinutes(configuration.getMessageCacheConfiguration().getPersistDelayMinutes()),
|
Duration.ofMinutes(configuration.getMessageCacheConfiguration().getPersistDelayMinutes()),
|
||||||
namespace.getInt(WORKER_COUNT),
|
namespace.getInt(WORKER_COUNT),
|
||||||
environment.lifecycle().executorService("messagePersisterUnlinkDeviceExecutor-%d")
|
environment.lifecycle().executorService("messagePersisterUnlinkDeviceExecutor-%d")
|
||||||
|
|
|
@ -54,8 +54,6 @@ public class ScheduledApnPushNotificationSenderServiceCommand extends ServerComm
|
||||||
|
|
||||||
final CommandDependencies deps = CommandDependencies.build("scheduled-apn-sender", environment, configuration);
|
final CommandDependencies deps = CommandDependencies.build("scheduled-apn-sender", environment, configuration);
|
||||||
|
|
||||||
MetricsUtil.configureRegistries(configuration, environment, deps.dynamicConfigurationManager());
|
|
||||||
|
|
||||||
if (configuration.getServerFactory() instanceof DefaultServerFactory defaultServerFactory) {
|
if (configuration.getServerFactory() instanceof DefaultServerFactory defaultServerFactory) {
|
||||||
defaultServerFactory.getApplicationConnectors()
|
defaultServerFactory.getApplicationConnectors()
|
||||||
.forEach(connectorFactory -> {
|
.forEach(connectorFactory -> {
|
||||||
|
@ -65,7 +63,6 @@ public class ScheduledApnPushNotificationSenderServiceCommand extends ServerComm
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final FaultTolerantRedisCluster pushSchedulerCluster = new FaultTolerantRedisCluster("push_scheduler",
|
final FaultTolerantRedisCluster pushSchedulerCluster = new FaultTolerantRedisCluster("push_scheduler",
|
||||||
configuration.getPushSchedulerCluster(), deps.redisClusterClientResources());
|
configuration.getPushSchedulerCluster(), deps.redisClusterClientResources());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue