From bc54582c5ec9f1b8e0383eaa8628db3bca88f041 Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 16 May 2019 11:03:34 +0200 Subject: [PATCH] Make use of pre-existing context in InstrumentRoundTripperTrace Fixes #580 Signed-off-by: beorn7 --- prometheus/promhttp/instrument_client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prometheus/promhttp/instrument_client.go b/prometheus/promhttp/instrument_client.go index d5172db..83c49b6 100644 --- a/prometheus/promhttp/instrument_client.go +++ b/prometheus/promhttp/instrument_client.go @@ -14,7 +14,6 @@ package promhttp import ( - "context" "crypto/tls" "net/http" "net/http/httptrace" @@ -213,7 +212,7 @@ func InstrumentRoundTripperTrace(it *InstrumentTrace, next http.RoundTripper) Ro } }, } - r = r.WithContext(httptrace.WithClientTrace(context.Background(), trace)) + r = r.WithContext(httptrace.WithClientTrace(r.Context(), trace)) return next.RoundTrip(r) })