diff --git a/platform-http-service-framework/build.gradle.kts b/platform-http-service-framework/build.gradle.kts index 4e8a688..392be2b 100644 --- a/platform-http-service-framework/build.gradle.kts +++ b/platform-http-service-framework/build.gradle.kts @@ -11,6 +11,7 @@ dependencies { api("com.google.inject:guice:5.1.0") api(project(":service-framework-spi")) + implementation(project(":platform-metrics")) implementation("org.slf4j:slf4j-api:1.7.36") implementation("com.google.inject.extensions:guice-servlet:5.1.0") implementation("com.google.guava:guava:31.1-jre") diff --git a/platform-http-service-framework/src/main/java/org/hypertrace/core/serviceframework/http/StandAloneHttpPlatformServiceContainer.java b/platform-http-service-framework/src/main/java/org/hypertrace/core/serviceframework/http/StandAloneHttpPlatformServiceContainer.java index a9d5502..261a2f6 100644 --- a/platform-http-service-framework/src/main/java/org/hypertrace/core/serviceframework/http/StandAloneHttpPlatformServiceContainer.java +++ b/platform-http-service-framework/src/main/java/org/hypertrace/core/serviceframework/http/StandAloneHttpPlatformServiceContainer.java @@ -3,21 +3,31 @@ import static io.grpc.Deadline.after; import static java.util.concurrent.TimeUnit.SECONDS; +import io.micrometer.core.instrument.binder.grpc.MetricCollectingClientInterceptor; import java.util.List; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.hypertrace.core.grpcutils.client.GrpcChannelRegistry; +import org.hypertrace.core.grpcutils.client.GrpcRegistryConfig; import org.hypertrace.core.serviceframework.PlatformService; import org.hypertrace.core.serviceframework.config.ConfigClient; import org.hypertrace.core.serviceframework.http.jetty.JettyHttpServerBuilder; +import org.hypertrace.core.serviceframework.metrics.PlatformMetricsRegistry; @Slf4j public abstract class StandAloneHttpPlatformServiceContainer extends PlatformService { private HttpContainer container; - private final GrpcChannelRegistry grpcChannelRegistry = new GrpcChannelRegistry(); + private final GrpcChannelRegistry grpcChannelRegistry; public StandAloneHttpPlatformServiceContainer(ConfigClient config) { super(config); + grpcChannelRegistry = + new GrpcChannelRegistry( + GrpcRegistryConfig.builder() + .defaultInterceptor( + new MetricCollectingClientInterceptor( + PlatformMetricsRegistry.getMeterRegistry())) + .build()); } protected abstract List getHandlerFactories();