feat(diagnostics): expose topology, SSE and cache metrics in the bundle - #1464
Open
arlenvasconcelos wants to merge 1 commit into
Open
feat(diagnostics): expose topology, SSE and cache metrics in the bundle#1464arlenvasconcelos wants to merge 1 commit into
arlenvasconcelos wants to merge 1 commit into
Conversation
Issue skyhook-io#1303 was slow to diagnose because the data needed to locate the bottleneck never reached us. The phase-level numbers were gated behind --dev and printed to stderr, which no bug reporter sends, and the one always-on store answered only "how long did a topology build take" with every build shape averaged into a single percentile. Everything here lands in pkg/perfstats and surfaces through /api/diagnostics and the overlay. No new stdout logging, no new flags, and every line is conditional so a healthy cluster grows the report by about five lines. - Split topology build stats by scope (full / scoped / refused). A namespace filter is what bounds the cost, so one duration window can no longer average a cluster-wide build with a namespace-scoped one. - Record the broadcast cycle: wall time, client groups, auth groups and marshal time. Auth groups are the fan-out multiplier that turns one slow build into a slow cycle, and were previously invisible. Recorded from a defer so cycles abandoned for a cluster switch report the time they spent instead of looking free. - Count abandoned, coalesced and retried cycles, plus the active debounce rung. - Sample the resource-change queue. Drops already surfaced once the channel overflowed; depth and the high-water mark show the approach to that cliff, and the received count gives the rate. - Time full topology rebuilds that run on a request goroutine because the relationship cache was dirty, and the edge-index builds with them. - Record how long the critical and deferred informer phases took. Per-kind stats deliberately carry no payload size: payload is measured at marshal time, downstream of the build and with no record of which kind produced it, so the field could only ever report zero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Issue #1303 was slow to diagnose because the data needed to locate the bottleneck never reached us. The phase-level numbers were gated behind --dev and printed to stderr, which no bug reporter sends, and the one always-on store answered only "how long did a topology build take" with every build shape averaged into a single percentile.
Everything here lands in pkg/perfstats and surfaces through /api/diagnostics and the overlay. No new stdout logging, no new flags, and every line is conditional so a healthy cluster grows the report by about five lines.
Per-kind stats deliberately carry no payload size: payload is measured at marshal time, downstream of the build and with no record of which kind produced it, so the field could only ever report zero.
Type of change
How has this been tested?
Describe the tests you ran to verify your changes.
Checklist
Related issues
Fixes #(issue number)
Note
Low Risk
Observability-only: atomic counters and sampled ring buffers on existing paths; no auth, data, or broadcast logic changes beyond recording metrics.
Overview
Adds always-on performance instrumentation in
pkg/perfstatsand wires it through the SSE broadcaster, topology builder, and informer cache so bug reports and/api/diagnosticscan show where time goes—not a single blended topology-build percentile.Topology builds are recorded as full / scoped / refused (
BuildKind), so a multi-second cluster-wide build no longer hides inside namespace-scoped p95s. The builder tags refused large-cluster guard paths separately from completed graphs.SSE gains counters for coalesced broadcast requests, abandoned cycles after cluster switches, retries when the worker re-arms, and the active debounce ladder rung. Each broadcast cycle records wall time, client-group vs auth-group fan-out (clone/strip/marshal multiplier), and aggregate marshal time. The change watcher samples queue depth (throttled) and tracks high-water on the resource-change channel.
Relationship cache paths time on-demand full rebuilds on request goroutines and IndexByResource builds.
Informer sync exposes critical and deferred phase wall times in cache sync status. The web diagnostics overlay and GitHub export show these fields conditionally so quiet clusters stay short.
Reviewed by Cursor Bugbot for commit 52dfe52. Bugbot is set up for automated code reviews on this repo. Configure here.