Telemetry is implemented in packages/core/src/telemetry/. It is off unless enabled — the settings default is undefined and the SDK exits early when telemetry is disabled.
Settings
The telemetry settings object accepts:
| Key | Meaning |
|---|---|
enabled | Master switch. |
traces | Enable trace export. |
target | local or gcp. |
otlpEndpoint | Collector endpoint; defaults to http://localhost:4317. |
otlpProtocol | grpc or http. |
otlpHeaders | Headers for the collector. |
logPrompts | Include prompt text and tool arguments in telemetry. |
outfile | Append telemetry as JSON to a local file. |
useCollector | Use a collector pipeline. |
useCliAuth | Use CLI credentials for telemetry auth. |
{
"telemetry": {
"enabled": true,
"target": "local",
"otlpProtocol": "grpc"
},
"privacy": {"usageStatisticsEnabled": false}
}Environment variables
The telemetry config uses an allow-list of variables:
M31A_TELEMETRY_ENABLEDM31A_TELEMETRY_TRACES_ENABLEDM31A_TELEMETRY_TARGETM31A_TELEMETRY_OTLP_ENDPOINTM31A_TELEMETRY_OTLP_PROTOCOLM31A_TELEMETRY_OTLP_HEADERSM31A_TELEMETRY_LOG_PROMPTSM31A_TELEMETRY_OUTFILEM31A_TELEMETRY_USE_COLLECTORM31A_TELEMETRY_USE_CLI_AUTHOTEL_EXPORTER_OTLP_ENDPOINTOTEL_EXPORTER_OTLP_HEADERS
Boolean values are true only for true or 1. Invalid target or protocol values are configuration errors. Related variables include M31A_STRICT_TELEMETRY_LIMITS, M31A_MEMORY_MONITOR_INTERVAL, and M31A_EVENT_LOOP_MONITOR_ENABLED.
Precedence
Highest to lowest: CLI arguments → environment → settings. Exceptions: traces, useCollector, and useCliAuth have no CLI-argument override. Headers are merged from settings, OTEL_EXPORTER_OTLP_HEADERS, M31A_TELEMETRY_OTLP_HEADERS, and CLI arguments.
Exporters
- Valid endpoint and no
outfile— OTLP export over gRPC or HTTP. outfileset — JSON append exporters to a local file.- Neither — console exporters.
Metric export uses a 10-second interval.
Privacy
- Prompt text and tool arguments are emitted only when
logPromptsis true. Otherwise the recorded prompt body is a length-only message. - Event names cover configuration, user prompts, tool calls, API requests, errors and responses, compression, rewind, slash commands, model routing, approval mode, hooks, and agent lifecycle.
- Keep
logPromptsunset for sensitive work, and usesecurity.environmentVariableRedactionto protect secrets from logs and exported sessions.
Next steps
See Settings, Environment variables, and Security.