Skip to content

Commit

Permalink
tsdb: register metrics after Head is initialized (prometheus#12876)
Browse files Browse the repository at this point in the history
This avoids situations where metrics are scraped before the data they
are trying to look at is initialized.

Signed-off-by: Bryan Boreham <[email protected]>
  • Loading branch information
bboreham committed Sep 25, 2023
1 parent a15e884 commit 6dcbd65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tsdb/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func NewHead(r prometheus.Registerer, l log.Logger, wal, wbl *wlog.WL, opts *Hea
if err := h.resetInMemoryState(); err != nil {
return nil, err
}
h.metrics = newHeadMetrics(h, r)

if opts.ChunkPool == nil {
opts.ChunkPool = chunkenc.NewPool()
Expand All @@ -278,6 +277,7 @@ func NewHead(r prometheus.Registerer, l log.Logger, wal, wbl *wlog.WL, opts *Hea
if err != nil {
return nil, err
}
h.metrics = newHeadMetrics(h, r)

return h, nil
}
Expand Down

0 comments on commit 6dcbd65

Please sign in to comment.