From b4c1dbab37d628dd30522cd35a93c6f5121e0dec Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Wed, 21 Oct 2026 14:45:19 -0700 Subject: [PATCH] Log slow API requests with server spans and client timing --- docs/operations.md | 4 + internal/agents/audit.go | 2 +- internal/agents/critical.go | 4 +- internal/agents/inbox.go | 4 +- internal/agents/leadtools.go | 4 +- internal/agents/maincommit.go | 8 +- internal/agents/manager.go | 8 +- internal/agents/mergefacts.go | 6 +- internal/agents/mergein.go | 4 +- internal/agents/mergemain.go | 6 +- internal/agents/review.go | 8 +- internal/agents/snapshots.go | 6 +- internal/agents/subtasks.go | 6 +- internal/agents/tasks.go | 6 +- internal/agents/workflows.go | 4 +- internal/git/changes.go | 37 +++---- internal/git/git.go | 138 ++++++++++++++------------- internal/git/ignore.go | 4 +- internal/git/notes.go | 29 +++--- internal/git/rename.go | 41 ++++---- internal/git/snapshot.go | 19 ++-- internal/server/changes.go | 6 +- internal/server/files.go | 2 +- internal/server/server.go | 13 ++- internal/server/timing.go | 50 ++++++++++ internal/store/migrateids.go | 7 +- internal/store/store.go | 8 +- internal/store/traced.go | 95 ++++++++++++++++++ internal/trace/trace.go | 71 ++++++++++++++ mac/Sources/Byre/API.swift | 2 +- mac/Sources/Byre/RequestTiming.swift | 41 ++++++++ 31 files changed, 458 insertions(+), 185 deletions(-) create mode 100644 internal/server/timing.go create mode 100644 internal/store/traced.go create mode 100644 internal/trace/trace.go create mode 100644 mac/Sources/Byre/RequestTiming.swift diff --git a/docs/operations.md b/docs/operations.md index 7b6cece..0884dca 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -18,6 +18,10 @@ The service always runs from the app: `/Applications/Byre.app/Contents/Helpers/b `byre serve` exits when its executable is replaced (logging `executable replaced, exiting`) and launchd starts the new one. A missing path counts as not yet replaced, so the moment in `install.sh` between removing the old bundle and moving the new one in doesn't trigger it. The service log is owner-only (0600), including existing logs: Tailscale can put a sign-in URL there. Logs go to `~/Library/Logs/byre.log`; `launchctl print gui/$(id -u)/run.fc.byre` shows the service. +## Slow requests + +An API request that takes 200 ms or more is logged on both ends. The server's line, `request slow`, in `byre.log`, has the handler's time and its spans: each git process, SQL begin, exec and query, the wait for the store's write lock, and the tailnet `whois`. Every response also carries these spans in a `Server-Timing` header. On the client, `log show --start