Summary
Create docs/telemetry.md — a comprehensive reference for the OTel metrics exporter introduced in #85.
Motivation
The README currently has no telemetry section. Users cannot discover the feature, understand what is collected, or configure it without reading the source code. This violates tokf's transparency principle.
Contents
docs/telemetry.md should cover:
1. Quick-start
export TOKF_TELEMETRY_ENABLED=true
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
tokf run cargo build
2. Configuration reference
| Variable |
Default |
Description |
TOKF_TELEMETRY_ENABLED |
false |
Set to true, 1, or yes to enable |
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:4318 |
OTLP collector endpoint |
OTEL_EXPORTER_OTLP_PROTOCOL |
http |
http or grpc (grpc requires --features otel-grpc) |
OTEL_EXPORTER_OTLP_HEADERS |
(none) |
Comma-separated key=value headers |
OTEL_RESOURCE_ATTRIBUTES |
(none) |
OTel resource attributes; service.name extracted |
TOKF_OTEL_PIPELINE |
(none) |
Pipeline label added to every metric |
Config file: ~/.config/tokf/config.toml ([telemetry] section).
3. Metrics reference
| Metric |
Type |
Unit |
Description |
gen_ai.client.token.usage |
Histogram |
{token} |
Token usage per invocation (split by gen_ai.token.type: input/output) |
tokf.filter.input_lines |
Counter |
{line} |
Lines before filtering |
tokf.filter.output_lines |
Counter |
{line} |
Lines after filtering |
tokf.filter.lines_removed |
Counter |
{line} |
Lines removed |
tokf.compression.ratio |
Gauge |
1 |
output/input line ratio |
tokf.tokens.saved |
Counter |
{token} |
Estimated tokens saved |
tokf.filter.duration |
Histogram |
s |
Filter wall-clock time |
tokf.filter.invocations |
Counter |
{invocation} |
Total filter invocations |
Token counts are estimates (bytes / 4) — not exact tokenizer output.
4. Attributes
Every metric carries: tokf.filter.name, tokf.command, tokf.exit_code, tokf.pipeline, service.name, service.version.
5. Guarantees
6. Backend setup examples
Docker Compose snippets for: OTel Collector → Prometheus, Grafana, Jaeger, Datadog, Honeycomb.
7. Troubleshooting
Common problems: endpoint unreachable, missing otel-grpc feature, gRPC/HTTP mismatch, header auth format.
Acceptance Criteria
Summary
Create
docs/telemetry.md— a comprehensive reference for the OTel metrics exporter introduced in #85.Motivation
The README currently has no telemetry section. Users cannot discover the feature, understand what is collected, or configure it without reading the source code. This violates tokf's transparency principle.
Contents
docs/telemetry.mdshould cover:1. Quick-start
2. Configuration reference
TOKF_TELEMETRY_ENABLEDfalsetrue,1, oryesto enableOTEL_EXPORTER_OTLP_ENDPOINThttp://localhost:4318OTEL_EXPORTER_OTLP_PROTOCOLhttphttporgrpc(grpc requires--features otel-grpc)OTEL_EXPORTER_OTLP_HEADERSkey=valueheadersOTEL_RESOURCE_ATTRIBUTESservice.nameextractedTOKF_OTEL_PIPELINEConfig file:
~/.config/tokf/config.toml([telemetry]section).3. Metrics reference
gen_ai.client.token.usage{token}gen_ai.token.type:input/output)tokf.filter.input_lines{line}tokf.filter.output_lines{line}tokf.filter.lines_removed{line}tokf.compression.ratio1tokf.tokens.saved{token}tokf.filter.durationstokf.filter.invocations{invocation}Token counts are estimates (
bytes / 4) — not exact tokenizer output.4. Attributes
Every metric carries:
tokf.filter.name,tokf.command,tokf.exit_code,tokf.pipeline,service.name,service.version.5. Guarantees
tokf telemetry synccommand (see docs(telemetry): add docs/telemetry.md — metrics reference and backend setup guide #88) will replay unsynced events.6. Backend setup examples
Docker Compose snippets for: OTel Collector → Prometheus, Grafana, Jaeger, Datadog, Honeycomb.
7. Troubleshooting
Common problems: endpoint unreachable, missing
otel-grpcfeature, gRPC/HTTP mismatch, header auth format.Acceptance Criteria
docs/telemetry.mdcreated with all sections abovedocs/telemetry.md--otel-exportflag documented in the CLI flags table in README