Fix fetched chunk from store size in metric (#8971)

**What this PR does / why we need it**:
The `Size()` function on `chunk.Chunk` calls out to `func (ChunkRef)
Size() int` in the proto, which doesn't actually include the size of the
chunk data! We need to call `chunk.Data.Size()` for that.
integrate-laser
Danny Kopping 2 years ago committed by GitHub
parent e7b0d4d26e
commit de84737368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 5
      pkg/storage/chunk/fetcher/fetcher.go

@ -7,6 +7,10 @@
* [8953](https://github.com/grafana/loki/pull/8953) **dannykopping**: Querier: block queries by hash.
* [8851](https://github.com/grafana/loki/pull/8851) **jeschkies**: Introduce limit to require a set of labels for selecting streams.
##### Fixes
* [8971](https://github.com/grafana/loki/pull/8971) **dannykopping**: Stats: fix `Cache.Chunk.BytesSent` statistic and loki_chunk_fetcher_fetched_size_bytes metric with correct chunk size.
### All Changes
#### Promtail

@ -201,9 +201,10 @@ func (c *Fetcher) FetchChunks(ctx context.Context, chunks []chunk.Chunk, keys []
// to the cache asynchronously in the background and we lose the context
var bytes int
for _, c := range fromStorage {
bytes += c.Size()
size := c.Data.Size()
bytes += size
chunkFetchedSize.WithLabelValues("store").Observe(float64(c.Size()))
chunkFetchedSize.WithLabelValues("store").Observe(float64(size))
}
st := stats.FromContext(ctx)

Loading…
Cancel
Save