You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/manage/observability.md
+113-2Lines changed: 113 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
# Observability
1
+
##Observability
2
2
3
-
MCP Gateway includes production-grade OpenTelemetry instrumentation for distributed tracing, enabling you to monitor performance, debug issues, and understand request flows.
3
+
MCP Gateway includes production-grade OpenTelemetry instrumentation for distributed tracingand Prometheus-compatible metrics exposure.
4
4
5
5
## Documentation
6
6
@@ -23,3 +23,114 @@ mcpgateway
23
23
```
24
24
25
25
View traces at http://localhost:6006
26
+
27
+
## Prometheus metrics (important)
28
+
29
+
Note: the metrics exposure is wired from `mcpgateway/main.py` but the HTTP
30
+
handler itself is registered by the metrics module. The main application
31
+
imports and calls `setup_metrics(app)` from `mcpgateway.services.metrics`. The
32
+
`setup_metrics` function instruments the FastAPI app and registers the
33
+
Prometheus scrape endpoint using the Prometheus instrumentator; the endpoint
34
+
available to Prometheus scrapers is:
35
+
36
+
- GET /metrics/prometheus
37
+
38
+
The route is created by `Instrumentator.expose` inside
39
+
`mcpgateway/services/metrics.py` (not by manually adding a GET handler in
40
+
`main.py`). The endpoint is registered with `include_in_schema=True` (so it
41
+
appears in OpenAPI / Swagger) and gzip compression is enabled by default
42
+
(`should_gzip=True`) for the exposition handler.
43
+
44
+
### Env vars / settings that control metrics
45
+
46
+
-`ENABLE_METRICS` (env) — set to `true` (default) to enable instrumentation; set `false` to disable.
47
+
-`METRICS_EXCLUDED_HANDLERS` (env / settings) — comma-separated regexes for endpoints to exclude from instrumentation (useful for SSE/WS or per-request high-cardinality paths). The implementation reads `settings.METRICS_EXCLUDED_HANDLERS` and compiles the patterns.
48
+
-`METRICS_CUSTOM_LABELS` (env / settings) — comma-separated `key=value` pairs used as static labels on the `app_info` gauge (low-cardinality values only). When present, a Prometheus `app_info` gauge is created and set to 1 with those labels.
49
+
- Additional settings in `mcpgateway/config.py`: `METRICS_NAMESPACE`, `METRICS_SUBSYSTEM`. Note: these config fields exist, but the current `metrics` module does not wire them into the instrumentator by default (they're available for future use/consumption by custom collectors).
50
+
51
+
### Enable / verify locally
52
+
53
+
1. Ensure `ENABLE_METRICS=true` in your shell or `.env`.
0 commit comments