Skip to content

Commit bce72b9

Browse files
authored
tsdb: Introduced new constructor for LeveledCompactor to take in metrics (prometheus#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>
1 parent 2aaafae commit bce72b9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tsdb/compact.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ type LeveledCompactorOptions struct {
169169
// EnableOverlappingCompaction enables compaction of overlapping blocks. In Prometheus it is always enabled.
170170
// It is useful for downstream projects like Mimir, Cortex, Thanos where they have a separate component that does compaction.
171171
EnableOverlappingCompaction bool
172+
// Metrics is set of metrics for Compactor. By default, NewCompactorMetrics would be called to initialize metrics unless it is provided.
173+
Metrics *CompactorMetrics
172174
}
173175

174176
type PostingsDecoderFactory func(meta *BlockMeta) index.PostingsDecoder
@@ -214,11 +216,14 @@ func NewLeveledCompactorWithOptions(ctx context.Context, r prometheus.Registerer
214216
if pe == nil {
215217
pe = index.EncodePostingsRaw
216218
}
219+
if opts.Metrics == nil {
220+
opts.Metrics = NewCompactorMetrics(r)
221+
}
217222
return &LeveledCompactor{
218223
ranges: ranges,
219224
chunkPool: pool,
220225
logger: l,
221-
metrics: NewCompactorMetrics(r),
226+
metrics: opts.Metrics,
222227
ctx: ctx,
223228
maxBlockChunkSegmentSize: maxBlockChunkSegmentSize,
224229
mergeFunc: mergeFunc,

0 commit comments

Comments
 (0)