Expand description
Structured per-request API telemetry.
Opt-in via the telemetry config key (off | basic | full).
Writes one JSON record per API call to ~/.cache/synaps/api-log.jsonl
(mode 0600, O_NOFOLLOW — same hardening as the legacy usage log).
basic records timing + usage + cost. full additionally records
rate-limit headers and cache-diagnostics results when available.
Writes are best-effort: a broken log path must never break the request
pipeline. All errors are silently dropped (matching log_usage).
Structs§
- Cache
Diag Record - Cache-diagnostics result (beta
cache-diagnosis-2026-04-07). Only present when the user opted in viacache_diagnostics = true. - Context
Record - Request-shape context: what we sent, for correlating cache behavior.
- Rate
Limit Record - Rate-limit headroom captured from
anthropic-ratelimit-*response headers. Only recorded atfulllevel. - Telemetry
Record - One JSONL record per API call.
- Usage
Record - Token usage for one API call, including the cache-creation TTL breakdown.
Enums§
- Telemetry
Level - Telemetry verbosity level, parsed from the
telemetryconfig key.
Functions§
- ratelimit_
from_ headers - Extract rate-limit headroom from response headers.
- request_
id_ from_ headers - Extract the
request-idresponse header. - write_
record - Append a record to the telemetry log. Best-effort — all errors are silently dropped so a broken log path never breaks the request pipeline.