trace emits a structured log line carrying the per-request correlation id when one is present in the context. localgit does not own a logger because store is constructed without one; the only context available is the request context, so the line is a no-op when there is no request id. The point of t
(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
| 237 | // point of these traces is to surface in prod logs (which include request_id) |
| 238 | // when a per-request log line names a slow localgit call. |
| 239 | func (r sourceRepo) trace(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr) { |
| 240 | id := reqid.From(ctx) |
| 241 | if id == "" { |
| 242 | return |
| 243 | } |
| 244 | base := []slog.Attr{slog.String("request_id", id)} |
| 245 | slog.Default().LogAttrs(ctx, level, msg, append(base, attrs...)...) |
| 246 | } |
| 247 | |
| 248 | func fileBytes(files []content.File) int { |
| 249 | n := 0 |