From 4dcc99e080000564175cf8e6fa45ccb1d55d07e9 Mon Sep 17 00:00:00 2001 From: Sanket Mundra Date: Wed, 28 Aug 2024 17:30:11 +0530 Subject: [PATCH] update --- config-service-factory/build.gradle.kts | 1 + config-service-factory/gradle.lockfile | 2 +- .../config/service/ConfigServiceFactory.java | 20 ++++++++++++++----- .../service/metric/ConfigMetricsReporter.java | 9 ++++++--- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/config-service-factory/build.gradle.kts b/config-service-factory/build.gradle.kts index deb262ee..130cf01c 100644 --- a/config-service-factory/build.gradle.kts +++ b/config-service-factory/build.gradle.kts @@ -15,4 +15,5 @@ dependencies { implementation(projects.notificationRuleConfigServiceImpl) implementation(projects.notificationChannelConfigServiceImpl) implementation(projects.spanProcessingConfigServiceImpl) + implementation(commonLibs.hypertrace.framework.documentstore.metrics) } diff --git a/config-service-factory/gradle.lockfile b/config-service-factory/gradle.lockfile index 428b9d28..3a7f9c89 100644 --- a/config-service-factory/gradle.lockfile +++ b/config-service-factory/gradle.lockfile @@ -106,7 +106,7 @@ org.hypertrace.core.grpcutils:grpc-context-utils:0.13.4=compileClasspath,runtime org.hypertrace.core.grpcutils:grpc-server-rx-utils:0.13.4=runtimeClasspath,testRuntimeClasspath org.hypertrace.core.grpcutils:grpc-server-utils:0.13.4=runtimeClasspath,testRuntimeClasspath org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath -org.hypertrace.core.serviceframework:docstore-metrics:0.1.76=runtimeClasspath,testRuntimeClasspath +org.hypertrace.core.serviceframework:docstore-metrics:0.1.76=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hypertrace.core.serviceframework:platform-grpc-service-framework:0.1.76=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath org.hypertrace.core.serviceframework:platform-metrics:0.1.76=runtimeClasspath,testRuntimeClasspath org.hypertrace.core.serviceframework:platform-service-framework:0.1.76=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath diff --git a/config-service-factory/src/main/java/org/hypertrace/config/service/ConfigServiceFactory.java b/config-service-factory/src/main/java/org/hypertrace/config/service/ConfigServiceFactory.java index 5a16380b..93fb66b3 100644 --- a/config-service-factory/src/main/java/org/hypertrace/config/service/ConfigServiceFactory.java +++ b/config-service-factory/src/main/java/org/hypertrace/config/service/ConfigServiceFactory.java @@ -6,6 +6,7 @@ import io.grpc.Channel; import io.grpc.health.v1.HealthCheckResponse.ServingStatus; import java.time.Clock; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -17,6 +18,7 @@ import org.hypertrace.config.service.store.DocumentConfigStore; import org.hypertrace.core.documentstore.Datastore; import org.hypertrace.core.documentstore.DatastoreProvider; +import org.hypertrace.core.serviceframework.docstore.metrics.DocStoreCustomMetricReportingConfig; import org.hypertrace.core.serviceframework.grpc.GrpcPlatformService; import org.hypertrace.core.serviceframework.grpc.GrpcPlatformServiceFactory; import org.hypertrace.core.serviceframework.grpc.GrpcServiceContainerEnvironment; @@ -43,7 +45,10 @@ public List buildServices( this.grpcServiceContainerEnvironment = grpcServiceContainerEnvironment; Config config = grpcServiceContainerEnvironment.getConfig(SERVICE_NAME); return this.buildServices( - this.getLocalChannel(), config, this.buildChangeEventGenerator(config)); + this.getLocalChannel(), + config, + this.buildChangeEventGenerator(config), + Collections.emptyList()); } public void checkAndReportStoreHealth() { @@ -61,9 +66,12 @@ public void checkAndReportStoreHealth() { } public List buildServices( - Channel localChannel, Config config, ConfigChangeEventGenerator configChangeEventGenerator) { + Channel localChannel, + Config config, + ConfigChangeEventGenerator configChangeEventGenerator, + List configurationCounterConfig) { return Stream.of( - new ConfigServiceGrpcImpl(this.buildConfigStore(config)), + new ConfigServiceGrpcImpl(this.buildConfigStore(config, configurationCounterConfig)), new SpacesConfigServiceImpl(localChannel), new LabelsConfigServiceImpl(localChannel, config, configChangeEventGenerator), new LabelApplicationRuleConfigServiceImpl( @@ -89,10 +97,12 @@ protected ConfigChangeEventGenerator buildChangeEventGenerator(Config config) { .createConfigChangeEventGenerator(config, Clock.systemUTC()); } - protected ConfigStore buildConfigStore(Config config) { + protected ConfigStore buildConfigStore( + Config config, List configurationCounterConfig) { try { Datastore datastore = initDataStore(config.getConfig(GENERIC_CONFIG_SERVICE_CONFIG)); - new ConfigMetricsReporter(datastore, grpcServiceContainerEnvironment.getLifecycle()) + new ConfigMetricsReporter( + datastore, grpcServiceContainerEnvironment.getLifecycle(), configurationCounterConfig) .monitor(); ConfigStore configStore = new DocumentConfigStore(Clock.systemUTC(), datastore); this.store = configStore; diff --git a/config-service-impl/src/main/java/org/hypertrace/config/service/metric/ConfigMetricsReporter.java b/config-service-impl/src/main/java/org/hypertrace/config/service/metric/ConfigMetricsReporter.java index d4e37522..e8f4b951 100644 --- a/config-service-impl/src/main/java/org/hypertrace/config/service/metric/ConfigMetricsReporter.java +++ b/config-service-impl/src/main/java/org/hypertrace/config/service/metric/ConfigMetricsReporter.java @@ -1,7 +1,8 @@ package org.hypertrace.config.service.metric; -import java.util.Collections; +import java.util.List; import org.hypertrace.core.documentstore.Datastore; +import org.hypertrace.core.serviceframework.docstore.metrics.DocStoreCustomMetricReportingConfig; import org.hypertrace.core.serviceframework.docstore.metrics.DocStoreMetricsRegistry; import org.hypertrace.core.serviceframework.spi.PlatformServiceLifecycle; @@ -9,11 +10,13 @@ public class ConfigMetricsReporter { private final DocStoreMetricsRegistry metricsRegistry; public ConfigMetricsReporter( - final Datastore datastore, final PlatformServiceLifecycle lifecycle) { + final Datastore datastore, + final PlatformServiceLifecycle lifecycle, + List configurationCounterConfig) { metricsRegistry = new DocStoreMetricsRegistry(datastore) .withPlatformLifecycle(lifecycle) - .withCustomMetrics(Collections.emptyList()); + .withCustomMetrics(configurationCounterConfig); } public void monitor() {