Fix instrumentation panic if there is no response (#27567)

(cherry picked from commit f529223455)
This commit is contained in:
Sofia Papagiannaki
2020-09-17 10:44:02 +02:00
committed by Hugo Häggmark
parent 569e2a2c74
commit 4ca888c798
+2 -2
View File
@@ -84,9 +84,9 @@ func instrumentRoundtrip(datasourceName string, next http.RoundTripper) promhttp
promhttp.InstrumentRoundTripperInFlight(requestInFlight, next))).
RoundTrip(r)
// we avoid measing contentlength less the zero because it indicates
// we avoid measuring contentlength less than zero because it indicates
// that the content size is unknown. https://godoc.org/github.com/badu/http#Response
if res.ContentLength > 0 {
if res != nil && res.ContentLength > 0 {
responseSizeSummary.Observe(float64(res.ContentLength))
}