Skip to content

Rate limiting observability (metrics and tracing) #4553

Closed

Description

@jerm-dro

User Story

As an SRE,
I want metrics and tracing for rate limiting,
so that I can monitor enforcement and troubleshoot issues in production.

Context

See THV-0057: Rate Limiting for MCP Servers for full design details.

Acceptance Criteria

  • Decision counter increments on allowed and rejected requests, broken down by scope and operation type
  • Redis error counter increments on Redis failures, broken down by error type
  • Fail-open counter increments when a request is allowed through during Redis outage
  • Check latency histogram records Lua script round-trip time
  • All metrics use toolhive_ prefix following project conventions
  • Span attributes rate_limit.decision, rate_limit.rejected_by, rate_limit.fail_open present on request span
  • Unit: Verify each metric increments under the correct conditions
  • Unit: Verify span attributes are set on allowed, rejected, and fail-open paths
  • E2E: Send rate-limited traffic, scrape metrics endpoint, verify counters are non-zero

Dependencies

  • STORY-001 (core rate limit middleware exists to instrument)

Out of Scope

  • Alert definitions and runbooks (operational docs)
  • Dashboard templates

Activity

  1. added
    enhancement
    go
    kubernetes
    api
    on Apr 4, 2026
  2. Sanskarzz commented on May 26, 2026

    @Sanskarzz
    Collaborator

    @jerm-dro I would like to work on this issue please assign.

  3. jerm-dro commented on May 27, 2026

    @jerm-dro
    CollaboratorAuthor
  4. Sanskarzz commented on Jun 4, 2026

    @Sanskarzz
    Collaborator

    @jerm-dro For the rate-limit decision counter, should we increment once per request, or once per evaluated rate-limit scope?

    For example, if one request checks shared, per-user, and per-tool buckets, should that produce one metric sample or three? I recommend once per evaluated scope because it gives better production visibility into which limits are enforcing traffic.

  5. jerm-dro commented on Jul 10, 2026

    @jerm-dro
    CollaboratorAuthor

    Finished by #5701

  6. Sanskarzz commented on Jul 11, 2026

    @Sanskarzz
    Collaborator

    Hey @jerm-dro thanks for merging #5701

    I noticed that this issue was closed as completed. However, as mentioned in the PR description, #5701 was the first part of the rate-limit observability work, and the following items are still pending.

    • Request-span attributes
    • Fail-open metrics and observability

    I’m planning to continue with these follow-up PRs. Would you prefer to reopen this issue until the remaining work is completed, or should I create separate follow-up issues for each item?

  7. jerm-dro commented on Jul 13, 2026

    @jerm-dro
    CollaboratorAuthor

    @Sanskarzz sorry about that. Feel free to open a PR. I'll leave this issue closed. Thanks for seeing this through to completion!

  8. Sanskarzz commented on Jul 14, 2026

    @Sanskarzz
    Collaborator

    @jerm-dro
    Lately, I have been so busy. Now I have rasied a sequel PR for Request-span attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

apienhancementgokubernetesoperator

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions