From f52922345515b5cf558e233c860d0a0e3ce7a5bb Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki Date: Mon, 14 Sep 2020 14:05:47 +0300 Subject: [PATCH] Fix instrumentation panic if there is no response (#27567) --- pkg/models/datasource_cache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/models/datasource_cache.go b/pkg/models/datasource_cache.go index cfbdf5559d4..8991423b457 100644 --- a/pkg/models/datasource_cache.go +++ b/pkg/models/datasource_cache.go @@ -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)) }