Repository navigation
Suppress RPC metrics for agent health check loopback calls - #6929
Merged
sorindumitru merged 1 commit intoMay 18, 2026
Merged
Conversation
rausingh-rh
requested review from
MarcosDY,
amartinezfayo,
evan2645,
rturner3 and
sorindumitru
as code owners
May 3, 2026 11:44
rausingh-rh
force-pushed
the
fix-health-check-metrics-pollution
branch
from
May 3, 2026 12:01
b790366 to
8482381
Compare
rausingh-rh
force-pushed
the
fix-health-check-metrics-pollution
branch
2 times, most recently
from
May 11, 2026 17:02
fcf42de to
2f1ae52
Compare
The agent health check exercises the Workload API by making loopback calls (FetchX509Context and FetchX509Bundles) to its own UDS socket. These calls return PermissionDenied because the agent has no workload registration entry for itself, which is expected and treated as healthy. However, the RPC metrics middleware records these as status="PermissionDenied", polluting metrics and making it impossible to distinguish real workload permission errors from health check noise. Add a Discard() method to CallCounter and a postprocess middleware step that checks the caller PID via peertracker. When the caller is the agent itself (os.Getpid()), the RPC call counter is discarded before the metrics middleware can emit. This follows the existing pattern used for log suppression in the workload handler (isAgent/quietLogging). Fixes spiffe#5335 Signed-off-by: Raushan Singh <[email protected]>
rausingh-rh
force-pushed
the
fix-health-check-metrics-pollution
branch
from
May 18, 2026 08:50
2f1ae52 to
609b0db
Compare
sorindumitru
approved these changes
May 18, 2026
sorindumitru
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks @rausingh-rh!
MikeZappa87
pushed a commit
to MikeZappa87/spire
that referenced
this pull request
May 29, 2026
The agent health check exercises the Workload API by making loopback calls (FetchX509Context and FetchX509Bundles) to its own UDS socket. These calls return PermissionDenied because the agent has no workload registration entry for itself, which is expected and treated as healthy. However, the RPC metrics middleware records these as status="PermissionDenied", polluting metrics and making it impossible to distinguish real workload permission errors from health check noise. Add a Discard() method to CallCounter and a postprocess middleware step that checks the caller PID via peertracker. When the caller is the agent itself (os.Getpid()), the RPC call counter is discarded before the metrics middleware can emit. This follows the existing pattern used for log suppression in the workload handler (isAgent/quietLogging). Fixes spiffe#5335 Signed-off-by: Raushan Singh <[email protected]>
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.
Pull Request check list
Affected functionality
Agent RPC metrics for Workload API calls made by the agent's own health check (both the gRPC Health/Check service and the HTTP
/ready/liveendpoints). These internal loopback calls no longer emit per-call RPC metrics (counter and elapsed_time). Connection metrics are unaffected. Metrics for calls from real workloads are unaffected.Description of change
Discard()method totelemetry.CallCounterthat marks the counter as done without emitting metricsdiscardAgentCallMetricspostprocess middleware step in the agent endpoint middleware chain that checks the caller PID via peertracker; when the caller is the agent itself, the RPC call counter is discardedTestAgentCallMetricsDiscardedwith three cases: agent PID (suppressed), non-agent PID (emitted), and no peertracker (emitted)Which issue this PR fixes
Fixes #5335