Files
Carles GarciaandGitHub ecff132e51 frontend: refactor response metrics collection (#4997)
* frontend: refactor metrics collection

The main goal is to provide accurate inspected bytes metrics (and othes) in responses for a potential future fair-use policy. Until now, we were counting inspected bytes regardless of the cache. With this PR, the responses that come from cache do not count towards inspected bytes.

- ensure that we collect response metrics in the same way for all endpoints.
- add cache header to querier responses, to indicate whether the response came from the cache
- set 0 to metrics from cached querier responses

* Update changelog

* Ignore gosec integer conversion rule in a few lines
2025-06-05 17:04:18 +02:00

19 lines
275 B
Go

package combiner
import "net/http"
const (
TempoCacheHeader = "X-Tempo-Cache"
TempoCacheHit = "HIT"
TempoCacheMiss = "MISS"
)
func IsCacheHit(resp *http.Response) bool {
if resp == nil {
return false
}
return resp.Header.Get(TempoCacheHeader) == TempoCacheHit
}