diff --git a/httptransport/indexer_v1.go b/httptransport/indexer_v1.go index 944a90cad6..3ea13911f1 100644 --- a/httptransport/indexer_v1.go +++ b/httptransport/indexer_v1.go @@ -55,6 +55,8 @@ var _ http.Handler = (*IndexerV1)(nil) // ServeHTTP implements http.Handler. func (h *IndexerV1) ServeHTTP(w http.ResponseWriter, r *http.Request) { start := time.Now() + ctx := zlog.ContextWithValues(r.Context(), "request_id", r.Header.Get("x-request-id")) + r = r.WithContext(ctx) wr := responserecorder.NewResponseRecorder(w) defer func() { if f, ok := wr.(http.Flusher); ok { diff --git a/middleware/introspection/instrumentedhandler.go b/middleware/introspection/instrumentedhandler.go index 61df99e9b6..3240c05881 100644 --- a/middleware/introspection/instrumentedhandler.go +++ b/middleware/introspection/instrumentedhandler.go @@ -66,6 +66,8 @@ func InstrumentedHandler(endpoint string, traceOpts othttp.Option, next http.Han h = promhttp.InstrumentHandlerResponseSize(ResponseSize, h) h = promhttp.InstrumentHandlerTimeToWriteHeader(RequestDuration, h) return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := zlog.ContextWithValues(r.Context(), "request_id", r.Header.Get("x-request-id")) + r = r.WithContext(ctx) recorder := rr.NewResponseRecorder(w) h.ServeHTTP(recorder, r) zlog.Info(r.Context()).