Skip to content

Commit

Permalink
allegro-internal/flex-roadmap#819 added debug endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nastassia-dailidava committed Oct 15, 2024
1 parent f43cedc commit 4b51f69
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import io.envoyproxy.envoy.extensions.transport_sockets.tap.v3.Tap
import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
import io.envoyproxy.envoy.type.matcher.PathMatcher
import io.envoyproxy.envoy.type.matcher.StringMatcher
import io.micrometer.core.instrument.MeterRegistry
import org.springframework.boot.jackson.JsonComponent
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -39,7 +40,10 @@ import io.envoyproxy.envoy.config.core.v3.Node as NodeV3
import io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC as RBACFilter

@RestController
class SnapshotDebugController(val debugService: SnapshotDebugService) {
class SnapshotDebugController(
val debugService: SnapshotDebugService,
val meterRegistry: MeterRegistry
) {

/**
* Returns a textual representation of the snapshot for debugging purposes.
Expand Down Expand Up @@ -67,6 +71,26 @@ class SnapshotDebugController(val debugService: SnapshotDebugService) {
)
}

@GetMapping("/debug-metrics")
fun metrics(): ResponseEntity<String> {
val stringBuilder = StringBuilder()
try {
meterRegistry.meters.forEach {
try {
stringBuilder.append(it.id).append(it.measure()).append("\n")
} catch (e: Exception) {
stringBuilder.append(e.message)
}
}
} catch (e: Exception) {
stringBuilder.append(e.message)
}
return ResponseEntity(
stringBuilder.toString(),
HttpStatus.OK
)
}

@GetMapping("/snapshot-global")
fun globalSnapshot(@RequestParam(defaultValue = "false") xds: Boolean): ResponseEntity<SnapshotDebugInfo> {
return ResponseEntity(
Expand Down

0 comments on commit 4b51f69

Please sign in to comment.