Skip to main content

Agent telemetry

The agent runtime (/agent/mcp on apiome-mcp) can send every agent tools/call to your observability stack as an OpenTelemetry trace and two metrics, over OTLP/HTTP. Datadog, Honeycomb, Grafana, Splunk and most SIEM pipelines accept OTLP, either directly or through an OpenTelemetry Collector. Apiome uses no vendor SDK.

It is off until you set an endpoint. Every call is still recorded in the invocation audit whatever you choose here. See Agent access.

Turn it on​

Set these on the mcp service (or in apiome-mcp/.env) and restart apiome-mcp:

VariableDefaultWhat it is
APIOME_MCP_OTEL_EXPORTER_OTLP_ENDPOINTempty (off)The OTLP/HTTP root of your collector, for example http://otel-collector:4318. Spans go to <root>/v1/traces, metrics to <root>/v1/metrics. Must start with http:// or https://
APIOME_MCP_OTEL_EXPORTER_OTLP_HEADERSemptyHeaders sent with every export, as key=value pairs separated by commas (URL-encode spaces as %20), for example a vendor API key. Never logged
APIOME_MCP_OTEL_TRACES_SAMPLER_RATIO0.25Share of calls traced (0 to 1). Metrics count every call whatever the ratio
APIOME_MCP_OTEL_SERVICE_NAMEapiome-mcpThe service.name your backend groups the data under
APIOME_MCP_OTEL_METRIC_EXPORT_INTERVAL_SECONDS60Seconds between metric exports
APIOME_MCP_OTEL_EXPORT_TIMEOUT_SECONDS10The longest one export may take

On start-up apiome-mcp logs agent_telemetry_enabled with the collector's host.

Sampling and cost​

Exporting runs in the background, but building spans costs some CPU. On the agent runtime's own benchmark (a mock listPets call through the full HTTP stack, about 4 ms of CPU):

Sampling ratioCPU added per call
0.25 (default)about 1.5%
1 (every call traced)about 2.5%

Metrics always cover every call, so dashboards and alerts on call counts, error rates and latency are exact at any ratio. Traces are a sample.

A caller's decision wins. When a call arrives with a W3C traceparent (below), it is traced exactly when the caller's trace is sampled, whatever the ratio. A caller that traces everything gets every one of its calls.

What is exported​

The trace​

Each call is one span named apiome.agent.invocation (kind SERVER), with up to two children:

SpanWhenAttributes
vault.resolveprod toolsets, while the upstream credential is openedapiome.agent.credential_injected (true when a credential was bound to the host); on failure error.type = credential_unavailable
upstream.requestWhen the request is sent to the API, retries includedhttp.request.method, http.response.status_code; on failure error.type (timeout, unreachable, blocked, or the 5xx status)

A call refused before it reaches the API (invalid arguments, a method or size rail) has no children. A failed call's span has status ERROR, with its error code as the description.

The apiome.agent.invocation span carries the same values as the call's audit row, one attribute per column:

AttributeWhat it is
apiome.agent.tenant_idThe workspace
apiome.agent.key_idThe agent key's id (never the key)
apiome.agent.toolset_idThe toolset
apiome.agent.tool_nameThe MCP tool called
apiome.agent.targetprod or mock
apiome.agent.outcomesuccess, validation_failure, upstream_error, quota_rejected or internal_error
apiome.agent.error_codeThe machine reason, such as upstream_timeout (failed calls only)
apiome.agent.http_statusThe API's HTTP status, when it answered
apiome.agent.latency_msHow long the call took
apiome.agent.request_bytes, apiome.agent.response_bytesThe size of the arguments and of the result
apiome.agent.sampledWhether a body sample was kept for the call

Four more columns are on the way: apiome.agent.via, apiome.agent.version_id, apiome.agent.compile_fingerprint and apiome.agent.failure_class. They will appear on the span and the metrics automatically once the audit row records them.

The metrics​

MetricTypeUnit
apiome.agent.invocationsCountercalls
apiome.agent.latency_msHistogramms

Both are labelled with the span's attributes except apiome.agent.key_id and the three measured numbers (latency_ms, request_bytes, response_bytes). One series per key, or per call size, would overwhelm most backends. To break usage down by key, use the traces or the Usage tab.

What is never exported​

Arguments, request and response bodies, headers, URLs, upstream credentials and error messages never become telemetry. Only the attributes listed on this page are set. A test runs real calls whose arguments, bodies and credentials carry known markers, and fails if any of them appears in an exported byte.

Connect a trace to the agent's own trace​

If the agent (or the gateway in front of it) sends a W3C traceparent header, the apiome.agent.invocation span becomes a child of the caller's span, so the whole request shows as one trace. A tracestate header is passed along too. On a transport without HTTP headers, put traceparent and tracestate in the request's params._meta. A malformed value is ignored and the call starts its own trace.

Recipes​

Send to an OpenTelemetry Collector and let it forward to your vendor. That keeps vendor keys out of apiome-mcp and lets you batch, filter or fan out. Every recipe uses the same apiome-mcp setting:

APIOME_MCP_OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318

Datadog​

Use the Collector's Datadog exporter (or the Datadog Agent with OTLP ingest on port 4318):

receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
exporters:
datadog:
api:
key: ${env:DD_API_KEY}
site: datadoghq.com
service:
pipelines:
traces: { receivers: [otlp], exporters: [datadog] }
metrics: { receivers: [otlp], exporters: [datadog] }

Grafana (Tempo and Mimir, or Grafana Cloud)​

Forward OTLP to Grafana Cloud's OTLP gateway with basic auth (<instance id>:<token>, base64):

receivers:
otlp:
protocols:
http:
endpoint: 0.0.0.0:4318
exporters:
otlphttp/grafana:
endpoint: https://otlp-gateway-prod-eu-west-0.grafana.net/otlp
headers:
Authorization: Basic ${env:GRAFANA_OTLP_AUTH}
service:
pipelines:
traces: { receivers: [otlp], exporters: [otlphttp/grafana] }
metrics: { receivers: [otlp], exporters: [otlphttp/grafana] }

For a self-hosted Tempo and Mimir, point an otlphttp exporter at each one instead.

Straight to a vendor​

Backends that accept OTLP/HTTP directly need no Collector. For Honeycomb:

APIOME_MCP_OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io
APIOME_MCP_OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=YOUR_API_KEY

When the collector is down​

Telemetry never fails or slows a call. Spans wait in a bounded in-memory queue and are sent in the background. An export that fails or takes longer than the timeout is dropped and logged by the OpenTelemetry SDK, and the call has already returned. The invocation audit is written either way. Pending data is flushed when apiome-mcp shuts down.

Where next​