Skip to content

Instrument Prometheus metrics across the broker #5

@haasonsaas

Description

@haasonsaas

Summary

No metrics instrumentation exists. For a security-critical system, observability into request rates, error rates, grant decisions, and connector health is non-negotiable.

Required work

  • Add Prometheus client dependency and /metrics endpoint
  • Request metrics: counter and histogram by endpoint, method, status code
  • Session metrics: gauge of active sessions by tenant, counter of sessions created/revoked/expired
  • Grant metrics: counter by outcome (issued, denied, pending, revoked, expired), histogram of grant TTLs
  • Approval metrics: counter by outcome (approved, denied, expired), histogram of approval wait time
  • Artifact metrics: gauge of active artifacts by connector kind, counter of unwrap operations
  • Connector metrics: counter and latency histogram per connector per operation (GitHub API calls, Vault credential fetches, lease revocations)
  • Policy metrics: counter of policy evaluation outcomes (allowed, denied) by capability
  • Budget metrics: counter of budget exhaustion events per handle
  • Cleanup worker metrics: counter of items processed per type per pass, histogram of pass duration
  • Storage metrics: Postgres pool stats (active, idle, wait), Redis command latency

Files

  • New package: internal/metrics/ with metric registration
  • internal/api/httpapi/server.go — middleware for request metrics
  • internal/app/service.go — instrument decision points
  • internal/connectors/*/ — instrument external calls
  • internal/worker/runner.go — instrument cleanup passes
  • cmd/asb-api/main.go — register /metrics handler

Priority

High — required for operational visibility.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions