From 77c3c5553522175451fd12784bf7c682bc2b0f9f Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Sun, 20 Oct 2024 16:20:13 +0200 Subject: [PATCH] allegro-internal/flex-roadmap#819 returned ControlPlaneConfig --- .../infrastructure/ControlPlaneConfig.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt index 8d50b62b5..6b88dc8a3 100644 --- a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt +++ b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt @@ -3,6 +3,7 @@ package pl.allegro.tech.servicemesh.envoycontrol.infrastructure import com.ecwid.consul.v1.ConsulClient import com.fasterxml.jackson.databind.ObjectMapper import io.micrometer.core.instrument.MeterRegistry +import io.micrometer.core.instrument.Tags import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.boot.context.properties.ConfigurationProperties @@ -40,6 +41,10 @@ import pl.allegro.tech.servicemesh.envoycontrol.services.transformers.RegexServi import pl.allegro.tech.servicemesh.envoycontrol.services.transformers.ServiceInstancesTransformer import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.EnvoyHttpFilters import pl.allegro.tech.servicemesh.envoycontrol.synchronization.GlobalStateChanges +import pl.allegro.tech.servicemesh.envoycontrol.utils.CACHE_GROUP_COUNT_METRIC +import pl.allegro.tech.servicemesh.envoycontrol.utils.STATUS_TAG +import pl.allegro.tech.servicemesh.envoycontrol.utils.WATCH_ERRORS_METRIC +import pl.allegro.tech.servicemesh.envoycontrol.utils.WATCH_METRIC import reactor.core.scheduler.Schedulers import java.net.URI @@ -172,7 +177,18 @@ class ControlPlaneConfig { ConsulClient(properties.host, properties.port).agentSelf.value?.config?.datacenter ?: "local" fun controlPlaneMetrics(meterRegistry: MeterRegistry): DefaultEnvoyControlMetrics { - return DefaultEnvoyControlMetrics(meterRegistry = meterRegistry) + return DefaultEnvoyControlMetrics(meterRegistry = meterRegistry).also { + meterRegistry.gauge(WATCH_METRIC, Tags.of(STATUS_TAG, "added"), it.servicesAdded) + meterRegistry.gauge(WATCH_METRIC, Tags.of(STATUS_TAG, "removed"), it.servicesRemoved) + meterRegistry.gauge(WATCH_METRIC, Tags.of(STATUS_TAG, "instance-changed"), it.instanceChanges) + meterRegistry.gauge(WATCH_METRIC, Tags.of(STATUS_TAG, "snapshot-changed"), it.snapshotChanges) + meterRegistry.gauge(CACHE_GROUP_COUNT_METRIC, it.cacheGroupsCount) + it.meterRegistry.more().counter( + WATCH_ERRORS_METRIC, + listOf(), + it.errorWatchingServices + ) + } } @Bean