Stop emitting metrics the MCP dashboard no longer queries#76
Conversation
The hosted MCP Grafana dashboard was curated down to six rows; drop every instrument whose panels were removed so we stop paying for unused series: - mcp_connection_total (Transport row removed; mcp_handshake_total remains the connection signal, so record_connection now emits handshakes only) - mcp_rate_limit_total / mcp_rate_limit_active (Rate Limiting row removed) - mcp_resource_* accessed/errors/size/anomaly (Resource Access row removed) - http_requests_total / http_request_duration_seconds and the HTTPMetricsMiddleware (HTTP Layer row removed) - legacy Appwrite-specific metrics never on the dashboard: appwrite calls/duration/errors, write confirmations, search_tools/search_docs, context requests, auth validations/duration, uploads Kept: tool execution, token usage, handshakes, activity sessions, messages/JSON-RPC errors, protocol versions, CPU/memory, server info. The telemetry docstring now states the contract: only metrics queried by appwrite-labs/dashboards mcp.json are emitted.
Greptile SummaryThis PR prunes the telemetry layer to match the curated Grafana dashboard, removing every metric instrument whose panel was dropped and establishing a client-name allowlist to bound
Confidence Score: 5/5Safe to merge — removes unused instrumentation with no changes to request handling, auth, or business logic. Every deleted metric has its call sites, record helpers, and tests removed consistently. The one new behavior — collapsing unknown client names to "other" — is additive cardinality protection and is well-covered by the new allowlist tests. No correctness-affecting paths were changed. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "(fix): bound client_id label values to a..." | Re-trigger Greptile |
client_id comes straight from client-controlled input (clientInfo.name / User-Agent), so any caller could mint arbitrary label values and blow up series cardinality on the Active Sessions by Client panel. Normalize names against KNOWN_MCP_CLIENTS (constants.py) — exact or '<entry>-…' prefixed, longest entry first — and collapse everything else to 'other'.
|
Added a second commit: |
The
MCPGrafana dashboard (appwrite-labs/dashboardsmcp.json) was curated down to six rows — Overview, Protocol & Messages, Tool Execution, Agentic & Token Metrics, Sessions & Connections, System Resources. This drops every instrument whose panels are gone, so we stop exporting series nothing reads:Removed (with their record helpers, call sites, and tests):
mcp_connection_total— Transport row removed;mcp_handshake_total{status="success"}remains the connection signal, so the initialize path now records handshakes onlymcp_rate_limit_total/mcp_rate_limit_active— Rate Limiting row removedmcp_resource_accessed/errors/size/access_anomaly— Resource Access row removedhttp_requests_total/http_request_duration_seconds+HTTPMetricsMiddleware— HTTP Layer row removedmcp_appwrite_calls/call_duration/errors,mcp_write_confirmations,mcp_search_tools_*,mcp_search_docs_*,mcp_context_requests,mcp_auth_validations/duration,mcp_uploads/upload_bytes/upload_errorsKept (everything
mcp.jsonqueries): tool calls/duration/errors/in-flight/result size, token usage (+per-call), handshakes, active sessions (+by client), session duration/disconnects, messages/latency/size, JSON-RPC errors, protocol versions, CPU/memory,mcp_server_info(dashboard variables).The telemetry module docstring now states the contract: only metrics queried by the hosted dashboard are emitted — remove a panel there, drop its instrument here.
Behavior otherwise unchanged: error monitoring (Sentry) paths, write-confirmation gating, and the identity middleware are untouched.
Testing: ruff/black/pyright clean, 160 unit tests pass, Docker build passes, and the ASGI app smoke-boots (healthz 200, unauthenticated /mcp 401).