mirror of
https://github.com/prometheus/prometheus
synced 2024-12-28 01:22:57 +00:00
Make head block ULIDs descriptive (#13100)
* Make head block ULIDs descriptive As far as I understand, these ULIDs aren't persisted anywhere, so it should be safe to change them. When debugging an issue, seeing an ULID like `2ZBXFNYVVFDXFPGSB1CHFNYQTZ` or `33DXR7JA39CHDKMQ9C40H6YVVF` isn't very helpful, so I propose to make them readable in their ULID string version. Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> * Set a different ULID for RangeHead Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com> --------- Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
This commit is contained in:
parent
1b84c01b76
commit
f997c72f29
10
tsdb/head.go
10
tsdb/head.go
@ -1407,11 +1407,13 @@ func (h *RangeHead) NumSeries() uint64 {
|
||||
return h.head.NumSeries()
|
||||
}
|
||||
|
||||
var rangeHeadULID = ulid.MustParse("0000000000XXXXXXXRANGEHEAD")
|
||||
|
||||
func (h *RangeHead) Meta() BlockMeta {
|
||||
return BlockMeta{
|
||||
MinTime: h.MinTime(),
|
||||
MaxTime: h.MaxTime(),
|
||||
ULID: h.head.Meta().ULID,
|
||||
ULID: rangeHeadULID,
|
||||
Stats: BlockStats{
|
||||
NumSeries: h.NumSeries(),
|
||||
},
|
||||
@ -1537,15 +1539,15 @@ func (h *Head) NumSeries() uint64 {
|
||||
return h.numSeries.Load()
|
||||
}
|
||||
|
||||
var headULID = ulid.MustParse("0000000000XXXXXXXXXXXXHEAD")
|
||||
|
||||
// Meta returns meta information about the head.
|
||||
// The head is dynamic so will return dynamic results.
|
||||
func (h *Head) Meta() BlockMeta {
|
||||
var id [16]byte
|
||||
copy(id[:], "______head______")
|
||||
return BlockMeta{
|
||||
MinTime: h.MinTime(),
|
||||
MaxTime: h.MaxTime(),
|
||||
ULID: ulid.ULID(id),
|
||||
ULID: headULID,
|
||||
Stats: BlockStats{
|
||||
NumSeries: h.NumSeries(),
|
||||
},
|
||||
|
@ -17,6 +17,8 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/oklog/ulid"
|
||||
|
||||
"github.com/prometheus/prometheus/tsdb/chunkenc"
|
||||
"github.com/prometheus/prometheus/tsdb/tombstones"
|
||||
)
|
||||
@ -135,13 +137,13 @@ func (oh *OOORangeHead) Tombstones() (tombstones.Reader, error) {
|
||||
return tombstones.NewMemTombstones(), nil
|
||||
}
|
||||
|
||||
var oooRangeHeadULID = ulid.MustParse("0000000000XXXX000RANGEHEAD")
|
||||
|
||||
func (oh *OOORangeHead) Meta() BlockMeta {
|
||||
var id [16]byte
|
||||
copy(id[:], "____ooo_head____")
|
||||
return BlockMeta{
|
||||
MinTime: oh.mint,
|
||||
MaxTime: oh.maxt,
|
||||
ULID: id,
|
||||
ULID: oooRangeHeadULID,
|
||||
Stats: BlockStats{
|
||||
NumSeries: oh.head.NumSeries(),
|
||||
},
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"math"
|
||||
|
||||
"github.com/oklog/ulid"
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/prometheus/prometheus/model/labels"
|
||||
@ -371,13 +372,13 @@ func (ch *OOOCompactionHead) Tombstones() (tombstones.Reader, error) {
|
||||
return tombstones.NewMemTombstones(), nil
|
||||
}
|
||||
|
||||
var oooCompactionHeadULID = ulid.MustParse("0000000000XX000COMPACTHEAD")
|
||||
|
||||
func (ch *OOOCompactionHead) Meta() BlockMeta {
|
||||
var id [16]byte
|
||||
copy(id[:], "copy(id[:], \"ooo_compact_head\")")
|
||||
return BlockMeta{
|
||||
MinTime: ch.mint,
|
||||
MaxTime: ch.maxt,
|
||||
ULID: id,
|
||||
ULID: oooCompactionHeadULID,
|
||||
Stats: BlockStats{
|
||||
NumSeries: uint64(len(ch.postings)),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user