Logs, Metrics and Traces
All off until set. No app code needed.
| Env var | What it does |
|---|---|
WISP_LOG=json | a JSON line per request on stdout (default off). A separate thread writes it. severity is INFO, WARNING (4xx) or ERROR (5xx). Past 4096 queued lines it drops lines and logs a dropped count |
METRICS_KEY | serves /_wisp/metrics (Prometheus text) to Authorization: Bearer <METRICS_KEY> |
OTEL_EXPORTER_OTLP_ENDPOINT | OTLP/HTTP JSON traces to <endpoint>/v1/traces |
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT | traces URL, used as is |
OTEL_SERVICE_NAME | service name on spans |
OTEL_EXPORTER_OTLP_HEADERS | api-key=…,x=… |
OTEL_BSP_SCHEDULE_DELAY | batch delay in ms (5000, at least 1) |
Logs
{"time":"2026-10-03T12:00:00.123Z","severity":"INFO","method":"GET","route":"/blog/[slug]","path":"/blog/hello","status":200,"ms":0.021,"bytes":1480,"id":"7f3a9c2e","ip":"203.0.113.7"}
ipiscx.client_ip()(seeWISP_CLIENT_IP_HEADER);idisx-request-id, generated if absent, echoed in the reply.
Metrics
A wrong or missing key gets 401; METRICS_KEY unset gets 404. Scrape with metrics_path: /_wisp/metrics and authorization: { credentials: <key> }.
| Metric | Notes |
|---|---|
wisp_requests_total{route, status} | status class like 2xx |
wisp_request_duration_seconds{route} | histogram, 1 ms to 10 s |
wisp_requests_in_flight | gauge |
wisp_uptime_seconds | gauge |
process_resident_memory_bytes | Linux only |
Traces
- One server span per request (
GET /blog/[slug]). - An incoming
traceparentis continued, and its sampled flag decides (W3C parent-based sampling). The reply carries its own (traceinWISP_LOG=json). On a public edge, drop the header at the proxy. - An endpoint path holding a space, CR or LF stops the server at start. Plain HTTP only: use a Collector for TLS.
let _s = wisp::span("charge card"); // child span until dropped, current across .await
let t = wisp::traceparent(); // Some("00-…-01"): header for a downstream call
Is This Page Useful?