tsdb: Introduced new constructor for LeveledCompactor to take in metrics (#16408)

* Introduced new constructor for LeveledCompactor to take in metrics

Signed-off-by: Alex Le <leqiyue@amazon.com>

* Added Metrics to LeveledCompactorOptions

Signed-off-by: Alex Le <leqiyue@amazon.com>

---------

Signed-off-by: Alex Le <leqiyue@amazon.com>
This commit is contained in:
Alex Le 2025-04-11 01:17:45 -07:00 committed by GitHub
parent 2aaafae36f
commit bce72b93d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -169,6 +169,8 @@ type LeveledCompactorOptions struct {
// EnableOverlappingCompaction enables compaction of overlapping blocks. In Prometheus it is always enabled.
// It is useful for downstream projects like Mimir, Cortex, Thanos where they have a separate component that does compaction.
EnableOverlappingCompaction bool
// Metrics is set of metrics for Compactor. By default, NewCompactorMetrics would be called to initialize metrics unless it is provided.
Metrics *CompactorMetrics
}
type PostingsDecoderFactory func(meta *BlockMeta) index.PostingsDecoder
@ -214,11 +216,14 @@ func NewLeveledCompactorWithOptions(ctx context.Context, r prometheus.Registerer
if pe == nil {
pe = index.EncodePostingsRaw
}
if opts.Metrics == nil {
opts.Metrics = NewCompactorMetrics(r)
}
return &LeveledCompactor{
ranges: ranges,
chunkPool: pool,
logger: l,
metrics: NewCompactorMetrics(r),
metrics: opts.Metrics,
ctx: ctx,
maxBlockChunkSegmentSize: maxBlockChunkSegmentSize,
mergeFunc: mergeFunc,