Skip to content

Commit

Permalink
chore: add ConfigMetricReporter to report metrics around configs (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanket-mundra authored Aug 30, 2024
1 parent aec20fe commit 9519fa1
Show file tree
Hide file tree
Showing 30 changed files with 109 additions and 34 deletions.
2 changes: 1 addition & 1 deletion alerting-config-service-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ io.grpc:grpc-protobuf:1.60.0=compileClasspath,runtimeClasspath,testCompileClassp
io.grpc:grpc-stub:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.annotation:javax.annotation-api:1.3.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
empty=annotationProcessor
2 changes: 1 addition & 1 deletion alerting-config-service-impl/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ org.apache.kafka:kafka-clients:7.5.2-ccs=compileClasspath,runtimeClasspath,testC
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.23=runtimeClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.eventstore:event-store:0.1.3=runtimeClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-client-rx-utils:0.13.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-client-utils:0.13.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion config-proto-converter/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ io.grpc:grpc-bom:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,t
io.grpc:grpc-protobuf-lite:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-protobuf:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
empty=annotationProcessor
2 changes: 1 addition & 1 deletion config-service-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ net.bytebuddy:byte-buddy-agent:1.14.10=testRuntimeClasspath
net.bytebuddy:byte-buddy:1.14.10=testRuntimeClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.23=testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-context-utils:0.13.4=testRuntimeClasspath
org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.8.0=testRuntimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion config-service-change-event-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ com.github.luben:zstd-jni:1.5.5-1=runtimeClasspath,testRuntimeClasspath
com.google.protobuf:protobuf-java:3.24.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-bom:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.apache.kafka:kafka-clients:7.5.2-ccs=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.lz4:lz4-java:1.8.0=runtimeClasspath,testRuntimeClasspath
org.slf4j:slf4j-api:2.0.7=runtimeClasspath,testRuntimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion config-service-change-event-generator/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0=testRuntimeClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.23=runtimeClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.eventstore:event-store:0.1.3=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-context-utils:0.13.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand Down
1 change: 1 addition & 0 deletions config-service-factory/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ dependencies {
implementation(projects.notificationRuleConfigServiceImpl)
implementation(projects.notificationChannelConfigServiceImpl)
implementation(projects.spanProcessingConfigServiceImpl)
implementation(commonLibs.hypertrace.framework.documentstore.metrics)
}
5 changes: 3 additions & 2 deletions config-service-factory/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ org.eclipse.jetty:jetty-servlet:9.4.53.v20231009=runtimeClasspath,testRuntimeCla
org.eclipse.jetty:jetty-util-ajax:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-util:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.hdrhistogram:HdrHistogram:2.1.12=runtimeClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.documentstore:document-store:0.7.65=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.documentstore:document-store:0.7.68=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.eventstore:event-store:0.1.3=runtimeClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-client-rx-utils:0.13.4=runtimeClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-client-utils:0.13.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-context-utils:0.13.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
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=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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
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;
import org.hypertrace.alerting.config.service.EventConditionConfigServiceImpl;
import org.hypertrace.config.service.change.event.api.ConfigChangeEventGenerator;
import org.hypertrace.config.service.change.event.impl.ConfigChangeEventGeneratorFactory;
import org.hypertrace.config.service.metric.ConfigMetricsReporter;
import org.hypertrace.config.service.store.ConfigStore;
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;
Expand All @@ -42,7 +45,11 @@ public List<GrpcPlatformService> 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),
grpcServiceContainerEnvironment,
Collections.emptyList());
}

public void checkAndReportStoreHealth() {
Expand All @@ -60,9 +67,14 @@ public void checkAndReportStoreHealth() {
}

public List<GrpcPlatformService> buildServices(
Channel localChannel, Config config, ConfigChangeEventGenerator configChangeEventGenerator) {
Channel localChannel,
Config config,
ConfigChangeEventGenerator configChangeEventGenerator,
GrpcServiceContainerEnvironment grpcServiceContainerEnvironment,
List<DocStoreCustomMetricReportingConfig> configurationCounterConfig) {
this.grpcServiceContainerEnvironment = grpcServiceContainerEnvironment;
return Stream.of(
new ConfigServiceGrpcImpl(this.buildConfigStore(config)),
new ConfigServiceGrpcImpl(this.buildConfigStore(config, configurationCounterConfig)),
new SpacesConfigServiceImpl(localChannel),
new LabelsConfigServiceImpl(localChannel, config, configChangeEventGenerator),
new LabelApplicationRuleConfigServiceImpl(
Expand All @@ -88,9 +100,13 @@ protected ConfigChangeEventGenerator buildChangeEventGenerator(Config config) {
.createConfigChangeEventGenerator(config, Clock.systemUTC());
}

protected ConfigStore buildConfigStore(Config config) {
protected ConfigStore buildConfigStore(
Config config, List<DocStoreCustomMetricReportingConfig> configurationCounterConfig) {
try {
Datastore datastore = initDataStore(config.getConfig(GENERIC_CONFIG_SERVICE_CONFIG));
new ConfigMetricsReporter(
datastore, grpcServiceContainerEnvironment.getLifecycle(), configurationCounterConfig)
.monitor();
ConfigStore configStore = new DocumentConfigStore(Clock.systemUTC(), datastore);
this.store = configStore;
return configStore;
Expand Down
1 change: 1 addition & 0 deletions config-service-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {

implementation(commonLibs.hypertrace.documentstore)
implementation(commonLibs.hypertrace.grpcutils.context)
implementation(commonLibs.hypertrace.framework.documentstore.metrics)

annotationProcessor(commonLibs.lombok)
compileOnly(commonLibs.lombok)
Expand Down
34 changes: 32 additions & 2 deletions config-service-impl/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ com.google.protobuf:protobuf-java:3.24.1=compileClasspath,runtimeClasspath,testC
com.typesafe:config:1.4.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
commons-io:commons-io:2.7=runtimeClasspath,testRuntimeClasspath
commons-logging:commons-logging:1.2=runtimeClasspath,testRuntimeClasspath
io.dropwizard.metrics:metrics-core:4.2.16=runtimeClasspath,testRuntimeClasspath
io.dropwizard.metrics:metrics-jvm:4.2.16=runtimeClasspath,testRuntimeClasspath
io.github.mweirauch:micrometer-jvm-extras:0.2.2=runtimeClasspath,testRuntimeClasspath
io.grpc:grpc-api:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-bom:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-context:1.60.0=runtimeClasspath,testCompileClasspath,testRuntimeClasspath
Expand All @@ -33,9 +36,24 @@ io.grpc:grpc-protobuf-lite:1.60.0=compileClasspath,runtimeClasspath,testCompileC
io.grpc:grpc-protobuf:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-stub:1.60.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.grpc:grpc-util:1.60.0=runtimeClasspath,testRuntimeClasspath
io.micrometer:micrometer-commons:1.10.2=runtimeClasspath,testRuntimeClasspath
io.micrometer:micrometer-core:1.10.2=runtimeClasspath,testRuntimeClasspath
io.micrometer:micrometer-observation:1.10.2=runtimeClasspath,testRuntimeClasspath
io.micrometer:micrometer-registry-prometheus:1.10.2=runtimeClasspath,testRuntimeClasspath
io.netty:netty-bom:4.1.108.Final=testCompileClasspath,testRuntimeClasspath
io.perfmark:perfmark-api:0.26.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient:0.16.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_common:0.16.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_dropwizard:0.12.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_pushgateway:0.12.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_servlet:0.12.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_servlet_common:0.12.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_tracer_common:0.16.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_tracer_otel:0.16.0=runtimeClasspath,testRuntimeClasspath
io.prometheus:simpleclient_tracer_otel_agent:0.16.0=runtimeClasspath,testRuntimeClasspath
javax.annotation:javax.annotation-api:1.3.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
javax.servlet:javax.servlet-api:3.1.0=runtimeClasspath,testRuntimeClasspath
javax.xml.bind:jaxb-api:2.3.0=runtimeClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy-agent:1.14.10=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.14.10=testCompileClasspath,testRuntimeClasspath
net.jodah:failsafe:2.4.4=runtimeClasspath,testRuntimeClasspath
Expand All @@ -47,19 +65,31 @@ org.apache.kafka:kafka-clients:7.5.2-ccs=compileClasspath,runtimeClasspath,testC
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.checkerframework:checker-qual:3.33.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.codehaus.mojo:animal-sniffer-annotations:1.23=runtimeClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.26=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.documentstore:document-store:0.7.65=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-http:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-io:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-security:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-server:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-servlet:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-util-ajax:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.eclipse.jetty:jetty-util:9.4.53.v20231009=runtimeClasspath,testRuntimeClasspath
org.hdrhistogram:HdrHistogram:2.1.12=runtimeClasspath,testRuntimeClasspath
org.hypertrace.bom:hypertrace-bom:0.3.27=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.documentstore:document-store:0.7.68=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.eventstore:event-store:0.1.3=runtimeClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-client-utils:0.13.4=testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.grpcutils:grpc-context-utils:0.13.4=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.kafkastreams.framework:kafka-bom:0.4.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.serviceframework:docstore-metrics:0.1.76=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.hypertrace.core.serviceframework:platform-metrics:0.1.76=runtimeClasspath,testRuntimeClasspath
org.hypertrace.core.serviceframework:service-framework-spi:0.1.76=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:5.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:5.10.0=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:5.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:5.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:1.10.0=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:1.10.0=testRuntimeClasspath
org.junit:junit-bom:5.10.0=testCompileClasspath,testRuntimeClasspath
org.latencyutils:LatencyUtils:2.0.3=runtimeClasspath,testRuntimeClasspath
org.lz4:lz4-java:1.8.0=runtimeClasspath,testRuntimeClasspath
org.mockito:mockito-core:5.8.0=testCompileClasspath,testRuntimeClasspath
org.mongodb:bson-record-codec:4.9.0=runtimeClasspath,testRuntimeClasspath
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.hypertrace.config.service.metric;

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;

public class ConfigMetricsReporter {
private final DocStoreMetricsRegistry metricsRegistry;

public ConfigMetricsReporter(
final Datastore datastore,
final PlatformServiceLifecycle lifecycle,
List<DocStoreCustomMetricReportingConfig> configurationCounterConfig) {
metricsRegistry =
new DocStoreMetricsRegistry(datastore)
.withPlatformLifecycle(lifecycle)
.withCustomMetrics(configurationCounterConfig);
}

public void monitor() {
metricsRegistry.monitor();
}
}
Loading

0 comments on commit 9519fa1

Please sign in to comment.