Skip to content

Commit 922f33d

Browse files
committed
httptransport: fix request_id logging
The final HTTP status message was getting an earlier Context which was missing the request_id key. Signed-off-by: Hank Donnay <[email protected]> (cherry picked from commit 378a4b5)
1 parent 5fd2656 commit 922f33d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

httptransport/indexer_v1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var _ http.Handler = (*IndexerV1)(nil)
5656
func (h *IndexerV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
5757
start := time.Now()
5858
wr := responserecorder.NewResponseRecorder(w)
59+
r = withRequestID(r)
5960
defer func() {
6061
if f, ok := wr.(http.Flusher); ok {
6162
f.Flush()
@@ -68,7 +69,7 @@ func (h *IndexerV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6869
Dur("duration", time.Since(start)).
6970
Msg("handled HTTP request")
7071
}()
71-
h.inner.ServeHTTP(wr, withRequestID(r))
72+
h.inner.ServeHTTP(wr, r)
7273
}
7374

7475
func (h *IndexerV1) indexReport(w http.ResponseWriter, r *http.Request) {

httptransport/matcher_v1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var _ http.Handler = (*MatcherV1)(nil)
6464
func (h *MatcherV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6565
start := time.Now()
6666
wr := responserecorder.NewResponseRecorder(w)
67+
r = withRequestID(r)
6768
defer func() {
6869
if f, ok := wr.(http.Flusher); ok {
6970
f.Flush()
@@ -76,7 +77,7 @@ func (h *MatcherV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
7677
Dur("duration", time.Since(start)).
7778
Msg("handled HTTP request")
7879
}()
79-
h.inner.ServeHTTP(wr, withRequestID(r))
80+
h.inner.ServeHTTP(wr, r)
8081
}
8182

8283
func (h *MatcherV1) vulnerabilityReport(w http.ResponseWriter, r *http.Request) {

httptransport/notification_v1.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func NewNotificationV1(_ context.Context, prefix string, srv notifier.Service, t
5656
func (h *NotificationV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
5757
start := time.Now()
5858
wr := responserecorder.NewResponseRecorder(w)
59+
r = withRequestID(r)
5960
defer func() {
6061
if f, ok := wr.(http.Flusher); ok {
6162
f.Flush()
@@ -68,7 +69,7 @@ func (h *NotificationV1) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6869
Dur("duration", time.Since(start)).
6970
Msg("handled HTTP request")
7071
}()
71-
h.inner.ServeHTTP(wr, withRequestID(r))
72+
h.inner.ServeHTTP(wr, r)
7273
}
7374

7475
func (h *NotificationV1) serveHTTP(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)