Repository navigation
2026 11 24 telemetry design
History. Shipped in #25, #30, #32 and #35. What it asked for now lives in the living spec: telemetry (TEL-1 to TEL-17), package (PKG-22), app (APP-6, where the call metrics sit) and facade (FAC-11). Overtaken: "Open for the builder" is answered by the plan 2026-11-24-telemetry-otel, design rows 1 to 12. TEL-13 is reworded by the plan 2026-11-24-telemetry-metrics: a provider already set is kept, kind by kind, and only the providers
QuickMCPset are shut down. Row 11 of the OpenTelemetry plan is accepted by Dr K, and TEL-15 says so.
Dr K wants to see where selenium-flow and mcp-kb spend CPU and memory, in Pyroscope, which now runs
in the homelab beside Prometheus, Loki and Tempo. selenium-flow already planned a /metrics endpoint
and traces for itself, in its telemetry issue (programme epic E4). Both servers are built on
QuickMCP, so the signals belong here, written once: profiles first, then traces, then metrics, each
one switched on by config.
The servers. Both run CPython 3.14 on Debian (glibc), as one process, in a container that's non-root, with a read-only root filesystem and every capability dropped. Neither has tracing today.
The ways a Python process reaches Pyroscope.
| Path | Code | Profile types |
|---|---|---|
eBPF from a node agent (Alloy's pyroscope.ebpf) |
none | CPU, optional off-CPU |
pyroscope-io, in-process |
one configure() at start |
CPU, wall-clock, memory |
pyroscope-otel on top of an OTel tracer |
the SDK plus tracing | profiles tied to trace spans |
Pull (pyroscope.scrape) |
a pprof endpoint | none for Python |
eBPF needs no code, and Python 3.14 on arm64 is within its unwinder's range. It needs a privileged DaemonSet, though. Dr K ruled it out: no extending privileges.
pyroscope-io is not plug and play. The wheel has no start-up hook and reads no environment
variables. Nothing runs until code calls pyroscope.configure(...), and every setting is an
argument to that call. Written once in QuickMCP, it serves every server. Memory profiling is
opt-in: mem_enabled=True adds allocated objects, allocated space, objects in use and space in use,
sampled about every 512 KiB allocated (mem_heap_sample_size). Its labels are per OS thread
(add_thread_tag, tag_wrapper), which is why TEL-10 refuses per-call labels in an async server.
Size. pyroscope-io 1.4.0 has no Python dependencies: it is one Rust extension. On
CPython 3.14 the aarch64 wheel is 5.6 MB and installs to 15 MB; the x86_64 one is 5.1 MB. The two
servers' images are 79 and 95 MiB compressed.
FastMCP traces itself. FastMCP 4 creates OpenTelemetry spans for tools, prompts, resources,
resource templates and tasks through the OTel API alone. They're a no-op until an SDK is
installed, and FASTMCP_TELEMETRY_MODE can turn them off or limit them to context propagation.
Exporting them takes a tracer provider and an OTLP exporter. opentelemetry-instrument from
opentelemetry-distro is the zero-code way to get one. TEL-11 installs the provider in code instead,
so the image keeps its entry point. TEL-12 keeps one that opentelemetry-instrument already
installed.
Read from FastMCP 4.2.5's docs/servers/telemetry.mdx, fastmcp/telemetry.py and
fastmcp/server/middleware/usage.py, the OpenTelemetry GenAI MCP conventions, and the
OpenTelemetry Python packages at 0.66b2 and 1.45.2.
Spans.
-
Names and attributes. FastMCP names its spans by the MCP conventions:
tools/call {name},prompts/get {name},resources/read(the URI goes inmcp.resource.uri),tasks/{op}, the list methods, and the method name for anything else. Their attributes aremcp.method.name,mcp.protocol.version,mcp.session.id,jsonrpc.request.id,gen_ai.tool.name,gen_ai.prompt.name,error.typeandrpc.response.status_code, plusfastmcp.server.name,fastmcp.component.*andfastmcp.provider.type. -
Shape. Each request has exactly one
SERVERspan. Mounted servers add anINTERNALdelegate {name}span. -
Context. Trace context arrives and leaves in the request's
_meta(traceparent,tracestate). -
Identity. With auth, spans carry
enduser.id(the token subject or client id) andenduser.scope. The trace backend therefore sees who called. - The provider. FastMCP looks the global tracer provider up per span, so it must be set before the first request. OpenTelemetry allows the global provider to be set only once per process. FastMCP's own test guidance is a session-scoped in-memory exporter.
Metrics already exist. fastmcp.server.middleware.usage.UsageMiddleware records
mcp.server.operation.duration, a histogram in seconds with the conventions' buckets from 10 ms to
300 s.
-
What it covers. Every
tools/callandprompts/get, carryingmcp.method.name, the tool or prompt name,error.type(tool_error, a JSON-RPC code,cancelled, or an exception class),rpc.status_code, the protocol version,network.*andfastmcp.server.name. - Bounded names. Unknown, disabled and unauthorized names are counted without the name, so they can't grow the series.
-
The user.
user_idishashed(needsuser_id_salt),raworomit. - Order. It must come first, before error handling and before any middleware that can answer without calling the next one.
-
Gaps. It records nothing until a meter provider exists. It doesn't record resource reads,
list calls, or
mcp.server.session.duration, another conventions metric. - Stability. The conventions are still in Development, and FastMCP warns the names may change.
Logs. OpenTelemetry's logging instrumentation (opentelemetry-instrumentation-logging)
does two things: with OTEL_PYTHON_LOG_CORRELATION=true it adds otelTraceID and otelSpanID to
records, and it can export records over OTLP. FastMCP's own records reach it only once its console
configuration is off (FASTMCP_LOG_ENABLED=false). APP-9 already makes them propagate.
OpenTelemetry's standard configuration can run from code.
opentelemetry.instrumentation.auto_instrumentation.initialize() is what opentelemetry-instrument
runs. It loads the distro, configures the SDK for traces, metrics and logs from the standard
OTEL_* variables (OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER,
OTEL_EXPORTER_OTLP_*, OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES), and then loads every
installed instrumentor. opentelemetry-distro defaults all three exporters to otlp over grpc.
A server that wants HTTP sets OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf, and one whose logs already
reach its log store from stdout sets OTEL_LOGS_EXPORTER=none. OTEL_METRICS_EXPORTER=prometheus
serves metrics on a port of its own (OTEL_EXPORTER_PROMETHEUS_PORT, default 9464), not on the
server's.
Span profiles are approximate in an async server. pyroscope-otel 1.1.0's
PyroscopeSpanProcessor tags the current thread with the span id, name and trace id when a
local-root span starts (no parent, or a remote one), and untags it when the span ends. The calls match
pyroscope-io 1.4's add_thread_tag(key, value). Overlapping calls share the event-loop thread, so
samples taken during the overlap carry another call's span. Work that runs in a worker thread carries
none.
Activity is counted over the year to 2026-11-23.
| Library | What it is | Stars | Releases | Downloads/month | Verdict |
|---|---|---|---|---|---|
pyroscope-io (grafana/pyroscope-rs) |
Grafana's profiling SDK | 224 | 26 | 12.7M | use |
pyroscope-otel (grafana/otel-profiling-python) |
ties profiles to spans | 10 | 3 | 1.2M | use, with traces |
opentelemetry-sdk / -distro (open-telemetry) |
the OTel SDK; distro adds the zero-code agent | 1130 | 34 | 19M | use the SDK |
opentelemetry-instrumentation-mcp (traceloop/openllmetry) |
MCP spans | 7551 | 44 | 2.3M | no: FastMCP traces natively, and stacking span hierarchies is a known FastMCP issue |
logfire (pydantic) |
an observability SDK aimed at its own service | 4566 | 47 | 18M | no: a vendor layer over OTel |
lite-bootstrap (modern-python) |
observability bootstrap with FastMCP and Pyroscope | 13 | 51 | 1.7k | no: one maintainer |
microbootstrap (community-of-python) |
the same, older | 71 | 24 | 3k | no: no licence on GitHub, a heavy core |
-
cbcoutinho/nextcloud-mcp-server, a Python MCP server.
pyroscope-iosits in anobservabilityextra, and the server's images install it. Profiling does nothing unless it's enabled and has an address. A missing package logs a warning instead of failing the import. It labels profiles with namespace and pod from the downward API, because every pod shares one application name. TEL-4 and TEL-9 follow it. -
lite-bootstrap's instruments each have
is_configured,dependencies_installed,bootstrapandteardown. That is the shape TEL-4 and TEL-5 describe, borrowed rather than depended on.
- No eBPF. No privileges are extended for profiling.
-
One
telemetryextra inpyproject.tomlholds every telemetry package (PKG-22). -
The images carry it, nothing else does. The selenium-flow and mcp-kb images install
kubed-mcp[telemetry]. A PyPI or source install doesn't get it unless asked. A separate image tag without it can come later. - Direct to the backends. A server pushes profiles to Pyroscope itself. Anything in between is a deployment's choice (Not now in the spec).
- One telemetry feature, delivered as one epic with a sub-issue per piece.
- CPU and memory both on by default when profiles are on (TEL-8).
-
OpenTelemetry is configured the standard way. One
otelswitch runs OpenTelemetry's own configuration, and every exporter setting is a standardOTEL_*variable (TEL-11, TEL-12). -
Metrics are pushed over OTLP, like traces. There is no route on the server's port, and the
prometheusexporter serves a scrape port for anyone who wants to pull (TEL-17). - Span profiles stay, flagged as approximate under overlapping calls (TEL-14).
- No user label on metrics (TEL-16).
- selenium-flow's telemetry issue is rescoped to what only selenium-flow has: its counters by surface and browser, and its own spans for routes and flow steps, built on this area.
-
profilesis an address, not a switch. Setting it is the switch, as with nextcloud-mcp-server'sPYROSCOPE_SERVER_ADDRESS. That gives one setting fewer to get wrong. -
The OTLP exporter reads the standard
OTEL_*variables (TEL-11) rather than settings of its own, so any OTLP backend's documentation applies unchanged. -
TelemetrySettingsships ready-made (TEL-3), so both servers embed the same section and their environment names stay alike. -
The pod labels come from
POD_NAMESPACEandPOD_NAME(TEL-9), the downward-API names nextcloud-mcp-server uses. It's the one place this area reads the environment directly. -
FastMCP's
UsageMiddlewareis the call metric (TEL-16), not a counter of our own. It follows the MCP conventions. selenium-flow's surface and browser stay selenium-flow's, as instruments of its own. -
The defaults in TEL-12: HTTP rather than gRPC, because the gRPC exporter pulls in
grpciofor a choice nobody here makes. No log export, because both servers' logs already reach their store from stdout. -
The extra carries the logging instrumentation (TEL-15), so trace ids on log records need no further install.
-
After the builder check:
- One service name drives profiles and traces (TEL-7), because Grafana matches the span's
service.nameto the Pyroscope application. - The pod's identity is on both signals (TEL-9, TEL-12).
- The first
QuickMCPin a process owns the signals (TEL-5). - CPU and memory map to the SDK's
cpu_enabledandmem_enabled(TEL-8).oncpustays the SDK's default. - An SDK that's already configured still gets the span link and the call metrics (TEL-13).
- One service name drives profiles and traces (TEL-7), because Grafana matches the span's
- The version floors in the extra, and whether
pyroscope-otelworks withpyroscope-io1.4'sadd_thread_tag(key, value). lite-bootstrap pinspyroscope-io>=1.0.1for that signature. - Where exactly the start sits: in
QuickMCP's own lifespan wrapper or inrun(), given TEL-5's order against APP-5. -
initialize()loads every instrumentor installed in the environment, not only the extra's. Check what the two servers' images carry. - With
OTEL_PYTHON_LOG_CORRELATION=true, the logging instrumentation can set the root logger's format throughlogging.basicConfig. Make sure it doesn't override the logging a server configured (APP-9). - Where
UsageMiddlewaresits againstQuickMCP's own outermost middleware (APP-6). It has to come before anything that can answer a request. - How TEL-13 tells an SDK that's already configured from the API's no-op default provider.
One epic in kubed-io/quick-mcp, with one sub-issue per piece, in order:
-
Profiles. The
telemetryextra,TelemetryandTelemetrySettings, the lifetime, and profiles (TEL-1 to TEL-10, PKG-22). - OpenTelemetry and traces. The standard configuration and its defaults, keeping an SDK that's already configured, the link to profiles, and trace ids on log records (TEL-11 to TEL-15).
- Metrics. FastMCP's call metrics, and metrics leaving as OpenTelemetry says (TEL-16, TEL-17).
-
Importing without FastMCP.
kubed.mcpresolves its names on first use, so a server's config can embedTelemetrySettingsin a layer that never loads FastMCP (FAC-11).
mcp-kb already serves through QuickMCP, and selenium-flow moved to it in selenium-flow#196. Each server adopts a piece in an issue
of its own, outside the epic, because a sub-issue's branch is
cut from its parent's in the same repository: a telemetry section in its config, its image
installing the extra, and its deployment setting the address.
These pages describe what is on main; the spec says what is built and what is only proposed.
kubed-mcp · MIT