Observability: watching your own deployment
agility-bridge serve, the Cloudflare Worker and the local stdio server can send one OpenTelemetry span for every MCP request
to a collector you run, so you can chart latency, error rate and Agility pressure. It is off by default, sends nothing
until you set an endpoint, and sends no content: no Agility text, no token, no workspace or person, no query, no address.
Turn it on
Section titled “Turn it on”| Setting | Meaning |
|---|---|
AB_OTEL_ENDPOINT |
The collector’s base URL, e.g. https://otel.example.com or http://127.0.0.1:4318. Spans are posted to <endpoint>/v1/traces as OTLP/HTTP JSON. HTTPS only, except loopback; no user name, query or fragment |
AB_OTEL_HEADERS |
Optional name=value,name2=value2 sent with every post, for a hosted collector’s API key. A secret: never logged, never in any output; on Workers set it as a secret (wrangler secret put AB_OTEL_HEADERS). Needs AB_OTEL_ENDPOINT |
At start the server logs one warning naming the collector’s host (never the path or the headers). Node batches spans and
sends them every five seconds and once more at shutdown. The Worker batches per isolate (D-324): finished spans (the
allowlisted attributes only, nothing else) wait in a queue and leave in one request when 64 are queued, when about 128 KiB are
queued, or after five seconds, whichever comes first. Every send runs in the waitUntil of the request that triggered it, so
nothing waits for the collector, (in the local Miniflare test, 70 requests made two collector requests). The queue holds 512 spans and about
256 KiB at most, with at most 4 sends in flight; past that the oldest span is dropped and counted. Spans still queued when
Cloudflare evicts an isolate are lost, at most five seconds of them (an idle isolate is usually kept longer than that, and the
wait that flushes the queue runs in the request that queued the first span); charts built from spans are statistics, not an audit
log (the audit log is in the database). A collector that is down, slow or refusing never changes or delays a response: the spans are dropped after
one attempt and a warning (the error class only, at most one a minute) says so. On the Workers Free plan each request makes one
more outgoing request for its span (45 Agility requests plus one is under the 50 allowed).
Unauthenticated traffic is sampled. A request that never authenticated (a 401, a 429 from the address limiter, or the
public catalogue) is recorded as a span at most 30 times a minute per
process or isolate; the rest are counted and not sent, so anyone who can reach the server cannot set the volume of the
collector’s bill or of the Worker’s outgoing requests. Every authenticated request still has its span. A caller’s
traceparent is used only for authenticated requests, so a caller can attach a span to a trace id of their choosing (the span
carries only the attributes below); it is never forwarded to Agility.
The collector is your choice. AB_OTEL_ENDPOINT is operator configuration, not caller input, so it is not held to the
public-address rule other outgoing requests follow: an internal collector (a private address or an internal name) is a normal
target. Set it only to a collector you trust; it receives the attributes below and the AB_OTEL_HEADERS credential.
The local stdio server
Section titled “The local stdio server”agility-bridge in stdio mode reads the same two settings from the environment your MCP client sets
(AB_OTEL_ENDPOINT, and AB_OTEL_HEADERS for a hosted collector’s key), with the same rules (HTTPS except loopback, headers need
the endpoint, a bad value stops start-up and names the variable, never the value). It sends one span per MCP request the client
makes and one per notification, with the same attribute names, the same fault classes and the same allowlist as above; what
differs:
- The span is taken from the frames on the pipe, not from an HTTP request.
http.response.status_codeis the HTTP-shaped status of the JSON-RPC answer: 200 for a result (a failed tool call is a 200 with itsAB_*code inerror.type, as over HTTP), 400 for a malformed or unknown request, 500 for our own failure, 202 for a notification. - There is no
agility_bridge.requests(the count of Agility requests of the call) and notraceparent: the client’s trace context is not read. There are no workspace, token or person to leave out; the arguments and Agility text are as private as on a server and are never read. - Spans are queued and sent every five seconds and once more when the client closes the pipe (a few seconds at most, 3 s per attempt). A collector that is down, slow or refusing never delays or changes a tool call and never writes to stdout, which carries MCP frames only; the failure is one warning on stderr at most a minute (the error class, never the endpoint or a header).
- An unconfigured server (the setup guidance) sends nothing.
- The start-up line is the same warning as
serve(on stderr), without the Agility request count.
What a span is
Section titled “What a span is”One span per MCP request, for every method (initialize, server/discover, ping, tools/list, tools/call, prompts,
resources, completion, subscriptions/listen, tasks, notifications), and for a request refused before any method ran. It ends
when the exchange ends, so a streamed answer has its real duration. The name is the method, plus the tool for a tool call
(tools/call get_sprint).
| Attribute | Values |
|---|---|
mcp.method.name |
A known MCP method, or other (a request refused before its body was read, or a method we do not know) |
agility_bridge.method_class |
tool_call, list, read, lifecycle, notification, listen, task, response, other |
gen_ai.tool.name |
A registered tool name, or unknown; only on tools/call |
http.response.status_code |
The HTTP status of the answer |
agility_bridge.outcome |
ok, refused (401, 403, 400, 405, 413, 415), rate_limited (429), failed |
agility_bridge.fault |
none, caller, upstream, server (below) |
error.type |
One of our stable AB_* error codes, or http_4xx / http_5xx |
agility_bridge.refusal |
Our own short reason for a refusal before a tool: no_token, token_malformed, rate_limited, body, method, unavailable, deadline, … |
agility_bridge.requests |
Agility requests the call used (a count) |
agility_bridge.request_id |
The request id that is also in the logs |
resource: service.name, service.version, deployment.environment.name |
agility-bridge, the version, production or test |
That is the whole list. There is no way to add an attribute from a tool, a workspace or a setting: every span passes through one function that keeps these keys and checks each value’s shape. Not exported, by design: workspace, user, grant, device, token, client address, arguments, queries, URIs, prompt names, asset text or numbers, error messages, member emails.
Error rate: whose fault is it?
Section titled “Error rate: whose fault is it?”A bad asset number is not an outage. Every failure is classed (the class is agility_bridge.fault), and the span status is
ERROR only for the last two:
| Fault | What it is | Examples (error.type) |
Span status |
|---|---|---|---|
none |
It worked | unset | |
caller |
The request is wrong, not allowed, or over a limit we set | AB_INPUT_INVALID, AB_NOT_FOUND, AB_AUTH_FORBIDDEN, AB_LIMIT_RATE, AB_BUDGET_EXHAUSTED, AB_AGILITY_AUTH (their own Agility token was refused), a refused or declined write, a 401 or 429 at the door |
unset |
upstream |
Agility did not deliver | AB_AGILITY_RATE_LIMITED, AB_AGILITY_TIMEOUT, AB_AGILITY_UNAVAILABLE, AB_AGILITY_TLS, AB_AGILITY_ERROR |
ERROR |
server |
Ours | AB_INTERNAL, AB_WRITE_AUDIT_UNAVAILABLE, AB_WRITE_LIMIT_UNAVAILABLE, a wrong instance URL, any 5xx (503 storage down, 504 deadline), and any code this table does not know yet |
ERROR |
Split upstream from server in a dashboard: an Agility outage and a bug in this server need different people.
Trace context
Section titled “Trace context”A request may carry a W3C traceparent. It is read strictly (00-<32 hex>-<16 hex>-<2 hex>, lower-case, no all-zero ids, nothing
after the flags; anything else is ignored and a new trace starts) and only on an authenticated request, so an anonymous caller
cannot put its own trace ids into your data. tracestate and baggage are never read. Trace headers are never sent to Agility
(the Agility client builds its own headers), and none is returned to the caller. Sampling is ours: every request is exported.
Recipes
Section titled “Recipes”These use the OpenTelemetry Collector’s spanmetrics connector to turn spans into metrics, then Prometheus rules. They were
written against the attribute list above and the span data was checked against a fake collector; they have not been run
against a real Prometheus or Grafana (unverified).
receivers: otlp: protocols: http: { endpoint: 0.0.0.0:4318 }connectors: spanmetrics: histogram: explicit: { buckets: [50ms, 200ms, 1s, 5s, 20s, 60s] } dimensions: - name: mcp.method.name - name: gen_ai.tool.name - name: agility_bridge.fault - name: agility_bridge.outcome - name: error.typeexporters: prometheus: { endpoint: 0.0.0.0:9464 }service: pipelines: traces: { receivers: [otlp], exporters: [spanmetrics] } metrics: { receivers: [spanmetrics], exporters: [prometheus] }The spanmetrics connector writes traces_span_metrics_calls_total and traces_span_metrics_duration_milliseconds_*, with the
dimensions as labels (dots become underscores):
# Service error rate (server and upstream faults): never caller faultssum(rate(traces_span_metrics_calls_total{status_code="STATUS_CODE_ERROR"}[5m])) / sum(rate(traces_span_metrics_calls_total[5m]))
# Only our own faultssum(rate(traces_span_metrics_calls_total{agility_bridge_fault="server"}[5m]))
# Agility pressure: throttling and slownesssum(rate(traces_span_metrics_calls_total{error_type="AB_AGILITY_RATE_LIMITED"}[5m]))sum(rate(traces_span_metrics_calls_total{agility_bridge_fault="upstream"}[5m]))
# p95 latency of tool calls, per toolhistogram_quantile(0.95, sum by (le, gen_ai_tool_name) (rate(traces_span_metrics_duration_milliseconds_bucket{agility_bridge_method_class="tool_call"}[5m])))
# Callers hitting our limits, and refused requests (a spike is a leaked or expired token, or a scan)sum(rate(traces_span_metrics_calls_total{agility_bridge_outcome="rate_limited"}[5m]))sum(rate(traces_span_metrics_calls_total{agility_bridge_outcome="refused"}[5m]))groups: - name: agility-bridge rules: - alert: AgilityBridgeServerFaults expr: sum(rate(traces_span_metrics_calls_total{agility_bridge_fault="server"}[10m])) > 0.05 for: 10m annotations: { summary: "agility-bridge is failing on its own (AB_INTERNAL, storage, deadline)" } - alert: AgilityUnavailable expr: | sum(rate(traces_span_metrics_calls_total{agility_bridge_fault="upstream"}[10m])) / sum(rate(traces_span_metrics_calls_total{agility_bridge_method_class="tool_call"}[10m])) > 0.2 for: 10m annotations: { summary: "More than 20% of tool calls fail because Agility does not answer" } - alert: AgilityThrottling expr: sum(rate(traces_span_metrics_calls_total{error_type="AB_AGILITY_RATE_LIMITED"}[10m])) > 0 for: 15m annotations: { summary: "Agility is rate limiting this deployment's tokens: lower AB_CALL_BUDGET or spread the callers" } - alert: AgilityBridgeSlowToolCalls expr: | histogram_quantile(0.95, sum by (le) (rate(traces_span_metrics_duration_milliseconds_bucket{agility_bridge_method_class="tool_call"}[10m]))) > 20000 for: 15m annotations: { summary: "p95 tool call latency above 20 s (the Agility request timeout)" }A dashboard needs five panels: request rate by mcp.method.name; service error rate (first query); faults by
agility_bridge.fault; p50 and p95 latency by tool; Agility requests per call (the agility_bridge.requests attribute on spans, in
a trace backend rather than as a metric label, since it is a number, not a category).
Cloudflare Workers Logs
Section titled “Cloudflare Workers Logs”On Cloudflare the committed apps/worker/wrangler.jsonc turns on
Workers Logs, traces and issue detection,
every request sampled and kept at Cloudflare for the dashboard (pnpm cf:setup copies the block into each deployment’s
config; change it there to sample less). This is separate from the spans above and needs no collector.
- What is kept: one invocation record per request or cron run (method, URL without its query string, status,
outcome, CPU and wall time, request headers), the Worker’s own log lines, and trace spans of its D1 queries and outgoing
requests. Cloudflare masks
Authorization,Cookieand any header named like a key, secret or token; query strings are dropped (redact_query_string) because sign-in and OAuth callbacks carry codes there. D1 spans show the SQL text with?placeholders, never the bound values. - Levels: each line is written with the console method of its level (
console.infoforinfoand so on), so the dashboard’s error count and issues are real errors. Before P9-28 every line went throughconsole.errorand everybootedorrequestline was shown as an error. - Turn it off: set
"observability": { "enabled": false }in the deployment’s local config and deploy again, or switch it off in the dashboard (the next deploy sets it back to the config).
Not covered
Section titled “Not covered”- Metrics and logs over OTLP: the backend derives metrics from spans (above), and logs stay on stderr, redacted (on Cloudflare, in Workers Logs).
- Per-workspace views. A workspace id is not exported; if you need it, the audit log has it per request id
(
agility_bridge.request_idis the join key). - A tool that fails inside a
200JSON-RPC error before it runs (an unknown tool name, an invalidtools/callenvelope) is a successful span: the answer was200.
agility-bridge is an unofficial, community project. It is not affiliated with, endorsed by, or supported by Digital.ai. Digital.ai, Agility and VersionOne are trademarks of their respective owners.