Rate limiting observability (metrics and tracing) PR C - #6282
Open
Sanskarzz wants to merge 1 commit into
Open
Conversation
Sanskarzz
requested review from
ChrisJBurns,
JAORMX,
amirejaz,
jerm-dro,
jhrozek and
tgrunnagle
as code owners
August 11, 2026 12:34
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Sanskarzz
force-pushed
the
ratelimiting-olly-3
branch
from
August 11, 2026 13:07
c64450a to
b6dcf1c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6282 +/- ##
==========================================
+ Coverage 72.81% 72.84% +0.02%
==========================================
Files 743 743
Lines 77647 77666 +19
==========================================
+ Hits 56538 56572 +34
+ Misses 17141 17130 -11
+ Partials 3968 3964 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Redis error metrics show that a rate-limit check failed, but they do not show
whether ToolHive applied its fail-open policy and allowed the operation to
continue. This leaves operators unable to distinguish an observed dependency
failure from an enforcement outcome for an individual request.
toolhive_rate_limit_fail_open, a counter with boundednamespaceandserverattributes, emitted once per failed shared enforcement check.ratelimit.Allowadapter used by MCPServer andVirtualMCPServer, without expanding the public limiter interface or
duplicating transport-specific instrumentation.
decision=allowed,rejected_by=none, andfail_open=truewhen enforcement proceeds after aRedis error.
retry behavior, and the existing mandatory fail-open policy.
Part of #4553
Type of change
Test plan
task test)task test-e2e)task lint-fix)Additional verification:
git diff --checkand VirtualMCPServer decorator
coverage proving no fail-open increment
Changes
pkg/ratelimit/limiter.gopkg/ratelimit/observability.gopkg/ratelimit/observability_test.gopkg/ratelimit/middleware_test.gopkg/vmcp/ratelimit/decorator_test.godocs/observability.mdDoes this introduce a user-facing change?
Yes. OpenTelemetry and Prometheus users can now identify rate-limit checks that
failed open. Prometheus exports the counter as
toolhive_rate_limit_fail_open_total.Request admission behavior and client responses are unchanged.
Implementation plan
Approved implementation plan
the Redis result is known, without claiming that fail-open has occurred.
not add a method to the exported
Limiterinterface.ratelimit.Allowenforcementadapter receives an infrastructure error, then return the original error so
MCPServer and VirtualMCPServer retain their existing logging and delegation.
toolhive_rate_limit_fail_openwith onlynamespaceandserverattributes and annotate the ambient request span as allowed through
fail-open.
toolhive_rate_limit_decisionsfor an errored Redis check,because Redis did not produce a bucket decision.
and both production enforcement paths with concrete closed-Redis tests.
Kubernetes E2E.
Special notes for reviewers
The package-level
ratelimit.Allowhelper records fail-open observability butstill returns the original limiter error. This deliberately preserves the
existing HTTP and VirtualMCPServer warning logs and their established behavior
of continuing the request after infrastructure failure.
The fail-open counter describes applied enforcement policy, while
toolhive_rate_limit_redis_errorsdescribes the underlying dependency failure.It intentionally has no tool, user, request, error, scope, or operation labels.