Send the request ID upstream and log it with each image
The fetcher sends the request ID chi's RequestID middleware put in the context as X-Request-Id, next to User-Agent and Accept, and the "upstream fetched", "image converted" and "image served" lines carry it as request_id, as the request log line does. A fetch shared by several requests runs with the first request's context values, so it carries that request's ID; README says so where it describes the shared fetch. Model: opus-5-5
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"sneak.berlin/go/pixa/internal/encurl"
|
||||
"sneak.berlin/go/pixa/internal/httpfetcher"
|
||||
"sneak.berlin/go/pixa/internal/imageprocessor"
|
||||
@@ -298,6 +299,7 @@ func (s *Handlers) writeImageResponse(
|
||||
// Log cache status and timing after serving
|
||||
duration := time.Since(startTime)
|
||||
s.log.Info("image served",
|
||||
"request_id", middleware.GetReqID(r.Context()),
|
||||
"cache_key", cacheKey,
|
||||
"cache_status", resp.CacheStatus,
|
||||
"duration_ms", duration.Milliseconds(),
|
||||
|
||||
Reference in New Issue
Block a user