mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: trace httpapi.{Read,Write} (#4134)
This commit is contained in:
@ -24,11 +24,12 @@ func RequestID(r *http.Request) uuid.UUID {
|
||||
func AttachRequestID(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
rid := uuid.New()
|
||||
ridString := rid.String()
|
||||
|
||||
ctx := context.WithValue(r.Context(), requestIDContextKey{}, rid)
|
||||
ctx = slog.With(ctx, slog.F("request_id", rid))
|
||||
|
||||
rw.Header().Set("X-Coder-Request-Id", rid.String())
|
||||
rw.Header().Set("X-Coder-Request-Id", ridString)
|
||||
next.ServeHTTP(rw, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user