From a09d8f45b9a803da248ac83cdbacc72a2847ad8d Mon Sep 17 00:00:00 2001 From: acelinkio <31336038+acelinkio@users.noreply.github.com> Date: Mon, 5 Jan 2026 00:21:25 -0800 Subject: [PATCH] auth/transcoder: associates the echo logs with request context (#1256) --- auth/main.go | 5 +++-- transcoder/main.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/auth/main.go b/auth/main.go index e963001b..856c53f0 100644 --- a/auth/main.go +++ b/auth/main.go @@ -272,8 +272,9 @@ func main() { LogUserAgent: true, HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error { + rCtx := c.Request().Context() if v.Error == nil { - logger.LogAttrs(ctx, slog.LevelInfo, "web_request", + logger.LogAttrs(rCtx, slog.LevelInfo, "web_request", slog.String("method", v.Method), slog.Int("status", v.Status), slog.String("host", v.Host), @@ -281,7 +282,7 @@ func main() { slog.String("agent", v.UserAgent), ) } else { - logger.LogAttrs(ctx, slog.LevelError, "web_request_error", + logger.LogAttrs(rCtx, slog.LevelError, "web_request_error", slog.String("method", v.Method), slog.Int("status", v.Status), slog.String("host", v.Host), diff --git a/transcoder/main.go b/transcoder/main.go index a7fc3874..76bf82a1 100644 --- a/transcoder/main.go +++ b/transcoder/main.go @@ -132,8 +132,9 @@ func main() { LogUserAgent: true, HandleError: true, // forwards error to the global error handler, so it can decide appropriate status code LogValuesFunc: func(c echo.Context, v middleware.RequestLoggerValues) error { + rCtx := c.Request().Context() if v.Error == nil { - logger.LogAttrs(ctx, slog.LevelInfo, "web_request", + logger.LogAttrs(rCtx, slog.LevelInfo, "web_request", slog.String("method", v.Method), slog.Int("status", v.Status), slog.String("host", v.Host), @@ -141,7 +142,7 @@ func main() { slog.String("agent", v.UserAgent), ) } else { - logger.LogAttrs(ctx, slog.LevelError, "web_request_error", + logger.LogAttrs(rCtx, slog.LevelError, "web_request_error", slog.String("method", v.Method), slog.Int("status", v.Status), slog.String("host", v.Host),