diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java index 3912ec94e..98af6a342 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/WhisperServerService.java @@ -21,6 +21,7 @@ import io.dropwizard.core.server.DefaultServerFactory; import io.dropwizard.core.setup.Bootstrap; import io.dropwizard.core.setup.Environment; import io.dropwizard.jetty.HttpsConnectorFactory; +import io.dropwizard.lifecycle.setup.LifecycleEnvironment; import io.grpc.ServerBuilder; import io.lettuce.core.metrics.MicrometerCommandLatencyRecorder; import io.lettuce.core.metrics.MicrometerOptions; @@ -364,8 +365,8 @@ public class WhisperServerService extends Application dynamicConfigurationManager = new DynamicConfigurationManager<>( @@ -397,8 +398,7 @@ public class WhisperServerService extends Application messageDeletionQueue = new LinkedBlockingQueue<>(); Metrics.gaugeCollectionSize(name(getClass(), "messageDeletionQueueSize"), Collections.emptyList(), messageDeletionQueue); - ExecutorService messageDeletionAsyncExecutor = environment.lifecycle() - .executorService(name(getClass(), "messageDeletionAsyncExecutor-%d")) + ExecutorService messageDeletionAsyncExecutor = ExecutorServiceBuilder.of(environment, "messageDeletionAsyncExecutor") .minThreads(2) .maxThreads(2) .allowCoreThreadTimeOut(true) @@ -503,98 +502,79 @@ public class WhisperServerService extends Application()) .keepAliveTime(io.dropwizard.util.Duration.seconds(60L)) .build(); - ExecutorService cloudflareTurnHttpExecutor = environment.lifecycle() - .executorService(name(getClass(), "cloudflareTurn-%d")) + ExecutorService cloudflareTurnHttpExecutor = ExecutorServiceBuilder.of(environment, "cloudflareTurn") .maxThreads(2) .minThreads(2) .build(); - ExecutorService googlePlayBillingExecutor = environment.lifecycle() - .virtualExecutorService(name(getClass(), "googlePlayBilling-%d")); - ExecutorService appleAppStoreExecutor = environment.lifecycle() - .virtualExecutorService(name(getClass(), "appleAppStore-%d")); - ExecutorService clientEventExecutor = environment.lifecycle() - .virtualExecutorService(name(getClass(), "clientEvent-%d")); - ExecutorService disconnectionRequestListenerExecutor = environment.lifecycle() - .virtualExecutorService(name(getClass(), "disconnectionRequest-%d")); + ExecutorService googlePlayBillingExecutor = virtualExecutorService(environment, "googlePlayBilling"); + ExecutorService appleAppStoreExecutor = virtualExecutorService(environment, "appleAppStore"); + ExecutorService clientEventExecutor = virtualExecutorService(environment, "clientEvent"); + ExecutorService disconnectionRequestListenerExecutor = virtualExecutorService(environment, "disconnectionRequest"); - ScheduledExecutorService appleAppStoreRetryExecutor = environment.lifecycle() - .scheduledExecutorService(name(getClass(), "appleAppStoreRetry-%d")).threads(1).build(); - ScheduledExecutorService subscriptionProcessorRetryExecutor = environment.lifecycle() - .scheduledExecutorService(name(getClass(), "subscriptionProcessorRetry-%d")).threads(1).build(); - ScheduledExecutorService cloudflareTurnRetryExecutor = environment.lifecycle() - .scheduledExecutorService(name(getClass(), "cloudflareTurnRetry-%d")).threads(1).build(); - ScheduledExecutorService messagePollExecutor = environment.lifecycle() - .scheduledExecutorService(name(getClass(), "messagePollExecutor-%d")).threads(1).build(); - ScheduledExecutorService provisioningWebsocketTimeoutExecutor = environment.lifecycle() - .scheduledExecutorService(name(getClass(), "provisioningWebsocketTimeout-%d")).threads(1).build(); + ScheduledExecutorService appleAppStoreRetryExecutor = ScheduledExecutorServiceBuilder.of(environment, "appleAppStoreRetry").threads(1).build(); + ScheduledExecutorService subscriptionProcessorRetryExecutor = ScheduledExecutorServiceBuilder.of(environment, "subscriptionProcessorRetry").threads(1).build(); + ScheduledExecutorService cloudflareTurnRetryExecutor = ScheduledExecutorServiceBuilder.of(environment, "cloudflareTurnRetry").threads(1).build(); + ScheduledExecutorService messagePollExecutor = ScheduledExecutorServiceBuilder.of(environment, "messagePollExecutor").threads(1).build(); + ScheduledExecutorService provisioningWebsocketTimeoutExecutor = ScheduledExecutorServiceBuilder.of(environment, "provisioningWebsocketTimeout").threads(1).build(); final ManagedNioEventLoopGroup dnsResolutionEventLoopGroup = new ManagedNioEventLoopGroup(); final DnsNameResolver cloudflareDnsResolver = new DnsNameResolverBuilder(dnsResolutionEventLoopGroup.next()) @@ -922,8 +902,7 @@ public class WhisperServerService extends Application getPendingMessages(@Auth AuthenticatedDevice auth, @@ -835,7 +832,6 @@ public class MessageController { return size; } - @Timed @DELETE @Path("/uuid/{uuid}") public CompletableFuture removePendingMessage(@Auth AuthenticatedDevice auth, @PathParam("uuid") UUID uuid) { @@ -874,7 +870,6 @@ public class MessageController { .thenApply(Util.ASYNC_EMPTY_RESPONSE); } - @Timed @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/report/{source}/{messageGuid}") diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/jetty/JettyHttpConfigurationCustomizer.java b/service/src/main/java/org/whispersystems/textsecuregcm/jetty/JettyHttpConfigurationCustomizer.java index c42eb8cad..3415c0086 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/jetty/JettyHttpConfigurationCustomizer.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/jetty/JettyHttpConfigurationCustomizer.java @@ -14,6 +14,8 @@ import org.eclipse.jetty.util.component.Container; import org.eclipse.jetty.util.component.LifeCycle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.micrometer.core.instrument.Metrics; +import io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics; /** * Uses {@link Container.Listener} to update {@link org.eclipse.jetty.server.HttpConfiguration} @@ -25,7 +27,6 @@ public class JettyHttpConfigurationCustomizer implements Container.Listener, Lif @Override public void beanAdded(final Container parent, final Object child) { if (child instanceof Connector c) { - for (ConnectionFactory cf : c.getConnectionFactories()) { final HttpConfiguration httpConfiguration = switch (cf) { case HTTP2ServerConnectionFactory h2cf -> h2cf.getHttpConfiguration(); @@ -39,6 +40,8 @@ public class JettyHttpConfigurationCustomizer implements Container.Listener, Lif httpConfiguration.setNotifyRemoteAsyncErrors(false); } } + + c.addBean(new JettyConnectionMetrics(Metrics.globalRegistry)); } } diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java b/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java index 3ff6d56bd..2f34a1ba4 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/push/ReceiptSender.java @@ -5,8 +5,6 @@ package org.whispersystems.textsecuregcm.push; -import io.micrometer.core.instrument.Metrics; -import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutorService; @@ -16,7 +14,6 @@ import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.entities.MessageProtos.Envelope; import org.whispersystems.textsecuregcm.identity.AciServiceIdentifier; import org.whispersystems.textsecuregcm.identity.ServiceIdentifier; -import org.whispersystems.textsecuregcm.metrics.MetricsUtil; import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil; import org.whispersystems.textsecuregcm.storage.AccountsManager; import org.whispersystems.textsecuregcm.storage.Device; @@ -33,9 +30,7 @@ public class ReceiptSender { final ExecutorService executor) { this.accountManager = accountManager; this.messageSender = messageSender; - this.executor = ExecutorServiceMetrics.monitor( - Metrics.globalRegistry, executor, MetricsUtil.name(ReceiptSender.class, "executor"), MetricsUtil.PREFIX) - ; + this.executor = executor; } public void sendReceipt(ServiceIdentifier sourceIdentifier, byte sourceDeviceId, AciServiceIdentifier destinationIdentifier, long messageId) {