chadtmiller.com/hud
A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts
place.hud.hudkit 0.5.0 Latest 5 packages
Logs as JSON lines in traces, kept for HUD's operators
MergedThis moves HUD to JSON-line logs in W3C traces. It adds a loopback /metrics and PUT /log, and an opt-in SQLite store (HUD_LOGS=on). Operators read the store through place.hud.getLogs and admin_logs. I read logs.rs, the server's telemetry.rs, the mcp.rs and xrpc.rs call sites, and the query-masking part of core telemetry.rs. I did not read the rest of core telemetry.rs, net.rs, main.rs, the CLI tests, the schema or the docs. The pull body says just check passes and the traced path was run by hand, so I leave those to the checks.
The parts I read look right.
- Access:
getLogsandadmin_logsare gated on the operator DID, and each read is logged. - Tool list:
admin_logsis listed to operators only. - Store: the file is created 0600 before SQLite opens it. Writes go in one transaction. A failed flush keeps its batch ahead of newer lines. Pruning keeps the last N lines at info and below, and drops any line older than 30 days.
- Tool calls:
mcp toollines never carry arguments or results.
Small things you may want to fix. None blocks the merge:
- Masked query names:
telemetry::querymatches names againstSECRETSas written. A percent-encoded name such as%63odebypasses the mask. Everything outside/oauthis logged and then kept 30 days, so decode the name before comparing. - Flush on the request path:
read_logscallslogs.flush()synchronously inside an async handler. The write can block a Tokio worker for a large pending batch. It also races the background flusher, so rows can land slightly out of order.spawn_blocking, or letting the flusher do the write, would avoid both. - Trace on streams:
tracedwraps onlynext.run(req). Work done while a streamed body is polled, such as the event stream, may log without the trace id.
crates/hud-core/src/logs.rsline 390
..Fields::default() | |
}; | |
telemetry::note(Level::INFO, "logs read", &f); | |
let read = logs.flush().and_then(|()| logs.read(&asked)); |
flush() here is blocking SQLite work on an async worker, and it can run at the same time as flushing's own flush, so ids can interleave out of order. Consider spawn_blocking, or flush under one lock.
HUD logs like knotless now: JSON lines on stderr in OpenTelemetry's names, each request in a W3C trace that its tool call and every outbound call share,
/metricsandPUT /logon a loopback listener, and withHUD_LOGS=onevery line kept inHUD_DATA_DIR/logs.dbfor the operators to read back withplace.hud.getLogsoradmin_logs. A deploy then no longer erases the record of what the iOS app'ssend_interactionscalls did.Claude Opus 5.5 · high
What changes
Lines.
hud_core::telemetrywrites every event as one JSON line on stderr (timestamp,level,message, the event's fields,target,trace_id), atRUST_LOG's level,infounset.hud startingnames the version, and the commit wheregit archivestamped it (crates/hud/commit.txt,export-subst: the deploy builds fromgit archive, so no infra change is needed). Panics are logged with where they happened.Traces. A request is in the trace its valid
traceparentnames, or a new one; the answer gives it back asx-trace-id. The formatter addstrace_idto every line logged while serving it, the existing ones included, and tasks a request starts keep it (telemetry::spawn: the blob download, a space tile's settling). Every outbound call sends its owntraceparent.One line per request, tool call and outbound call.
request(route template, eachplace.hud.*method by its path, path, query with secret-bearing values masked and none under/oauth, method, user agent, status, size,duration_ms): warn pastHUD_SLOW_MS(1000) except the event stream, error with its cause for a 5xx, debug for/_health.mcp tool/mcp tool failed(gen_ai.tool.name, caller's DID,is_error, the error,duration_ms; never arguments or results).outgoingfrom hud-core's net client (host, path,rpc.method, status,error.type, includingabandonedfor a call dropped unanswered), debug, warn on failure or slowness. They replace the ad hocxrpc,xrpc refused,xrpc stream openedandmcpinfo lines (XRPC errors now ride on the request line'serror).A summary each minute of requests, calls by host, and each
cache::Ttl's hits and misses (now counted with two atomics).HUD_METRICS(a loopback address, refused otherwise):GET /metrics(RED by route and by host, cache lookups, build info) andPUT /logwith aRUST_LOGdirective (the reload layer).HUD_LOGS=on: every line also goes to SQLite atHUD_DATA_DIR/logs.db, mode 0600, written every second off the request path, the oldest pending dropped past 50,000, never blocking. Lines at info and below kept to the lastHUD_LOGS_KEEP(500,000), every line at most 30 days, pruned each minute.Read back by
HUD_OPERATOR_DIDS:place.hud.getLogs(new lexicon; by web session or Bearer;trace,message,level,minMs,limit≤ 500;Forbiddenfor anyone else,NotFoundwhen nothing is kept), and the MCP tooladmin_logs, listed to operators alone and refusing anyone else. Each read is logged aslogs readwith who asked and for what.Docs:
docs/observability.md(new: what is logged, field names, traces, metrics, the kept lines, jq/journald recipes, what isn't built), env vars indocs/running.mdandhud --help,getLogsindocs/workspace-api.md,admin_logsindocs/tools.md, AGENTS.md's storage rule, and the privacy policy's Logs paragraph.Why
Tonight the grain box's
json-filelog went with each deploy, which hid whethersend_interactionshad been called. This follows knotless's observability (docs/observability.md there) adapted to HUD: env vars, not flags; HUD's own operators by DID; its one outbound client.How it was checked
just checkpasses: rustfmt, clippy-D warnings,just covat 100% lines and functions, svelte-check,just lint,just lex(the getLogs answers throughxrpc/tests.rs's router are held to the lexicon).target/debug/hud servewithHUD_LOGS=on,HUD_METRICS=127.0.0.1:<port>,HUD_OPERATOR_DIDS:PUT /log info,hud::outgoing=debug,...answeredlogging …; atools/callofdescribe_repoon bsky.app with atraceparentput itsoutgoinglines (PLC, the PDS's getRecord/describeRepo/listRecords, the AppView's getAuthorFeed), itsmcp toolline and itsrequestline all in that trace,x-trace-idechoed it;/metricsanswered on the loopback port with routes, hosts and cache lookups;getLogsrefused signed out and with a bogus token (AuthRequired);logs.db,-waland-shmwere 0600 and held the trace's lines after SIGTERM. The operator path is covered by router and MCP tests (no local sign-in).Shortcomings
hud starting, config errors) reach stderr only.git archive; a checkout's build names none.HUD_LOGS,HUD_OPERATOR_DIDSandHUD_METRICSneed setting there to take effect./metricsand/logare reached from a container in its network namespace (docs showcurlimages/curl).Review
Start at
crates/hud-core/src/telemetry.rs(the formatter, traces, lines, counts), thenlogs.rs, thenhud-server/src/telemetry.rsand themcp.rs/xrpc.rscall sites.