Skip to content

Commit

Permalink
allegro-internal/flex-roadmap#819 added debug endpoint changed type t…
Browse files Browse the repository at this point in the history
…o PrometheusMeterRegistry
  • Loading branch information
nastassia-dailidava committed Oct 15, 2024
1 parent 4b51f69 commit 9c1e502
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions envoy-control-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect'
api group: 'io.dropwizard.metrics', name: 'metrics-core', version: versions.dropwizard
api group: 'io.micrometer', name: 'micrometer-core'
api group: 'io.micrometer', name: 'micrometer-registry-prometheus'

implementation group: 'com.google.re2j', name: 're2j', version: versions.re2j

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package pl.allegro.tech.servicemesh.envoycontrol

import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.simple.SimpleMeterRegistry
import io.micrometer.prometheusmetrics.PrometheusConfig
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import java.util.concurrent.atomic.AtomicInteger

interface EnvoyControlMetrics {
Expand All @@ -21,7 +22,7 @@ data class DefaultEnvoyControlMetrics(
val snapshotChanges: AtomicInteger = AtomicInteger(),
val cacheGroupsCount: AtomicInteger = AtomicInteger(),
val errorWatchingServices: AtomicInteger = AtomicInteger(),
override val meterRegistry: MeterRegistry = SimpleMeterRegistry()
override val meterRegistry: MeterRegistry = PrometheusMeterRegistry(PrometheusConfig.DEFAULT)
) : EnvoyControlMetrics {

override fun errorWatchingServices() {
Expand Down
2 changes: 1 addition & 1 deletion envoy-control-runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
api group: 'org.springframework.boot', name: 'spring-boot-starter-web'
api group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
api group: 'org.springframework.boot', name: 'spring-boot-starter-security'
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus'
api group: 'io.micrometer', name: 'micrometer-registry-prometheus'

implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin'
implementation group: 'net.openhft', name: 'zero-allocation-hashing', version: versions.xxhash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContex
import io.envoyproxy.envoy.type.matcher.PathMatcher
import io.envoyproxy.envoy.type.matcher.StringMatcher
import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import org.springframework.boot.jackson.JsonComponent
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand Down Expand Up @@ -85,6 +86,15 @@ class SnapshotDebugController(
} catch (e: Exception) {
stringBuilder.append(e.message)
}

try {
if (meterRegistry is PrometheusMeterRegistry) {
stringBuilder.append("Prometheus")
.append((meterRegistry as PrometheusMeterRegistry).scrape())
}
} catch (e: Exception) {
stringBuilder.append(e.message)
}
return ResponseEntity(
stringBuilder.toString(),
HttpStatus.OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import pl.allegro.tech.servicemesh.envoycontrol.server.callbacks.MetricsDiscover
import pl.allegro.tech.servicemesh.envoycontrol.server.callbacks.MetricsDiscoveryServerCallbacks.StreamType.RDS
import pl.allegro.tech.servicemesh.envoycontrol.server.callbacks.MetricsDiscoveryServerCallbacks.StreamType.SDS
import pl.allegro.tech.servicemesh.envoycontrol.server.callbacks.MetricsDiscoveryServerCallbacks.StreamType.UNKNOWN
import pl.allegro.tech.servicemesh.envoycontrol.utils.CONNECTION_TYPE_TAG
import pl.allegro.tech.servicemesh.envoycontrol.utils.CONNECTIONS_METRIC
import pl.allegro.tech.servicemesh.envoycontrol.utils.CONNECTION_TYPE_TAG
import pl.allegro.tech.servicemesh.envoycontrol.utils.DISCOVERY_REQ_TYPE_TAG
import pl.allegro.tech.servicemesh.envoycontrol.utils.REQUESTS_METRIC
import pl.allegro.tech.servicemesh.envoycontrol.utils.STREAM_TYPE_TAG
Expand Down

0 comments on commit 9c1e502

Please sign in to comment.