Skip to content

Commit

Permalink
use reset for metrics; change default value for flag
Browse files Browse the repository at this point in the history
Signed-off-by: metonymic-smokey <[email protected]>
  • Loading branch information
metonymic-smokey committed Nov 6, 2021
1 parent 6999f7f commit 0660dc2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions cmd/thanos/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/thanos-io/thanos/pkg/logging"
"github.com/thanos-io/thanos/pkg/objstore/client"
"github.com/thanos-io/thanos/pkg/prober"
"github.com/thanos-io/thanos/pkg/receive"
"github.com/thanos-io/thanos/pkg/runutil"
httpserver "github.com/thanos-io/thanos/pkg/server/http"
"github.com/thanos-io/thanos/pkg/ui"
Expand Down Expand Up @@ -462,11 +461,10 @@ func runCompact(

if conf.compactionProgressMetrics {
g.Add(func() error {
unRegisterer := &receive.UnRegisterer{Registerer: reg}
ps := compact.NewCompactionProgressCalculator(unRegisterer, tsdbPlanner)
ps := compact.NewCompactionProgressCalculator(reg, tsdbPlanner)
var ds *compact.DownsampleProgressCalculator
if !conf.disableDownsampling {
ds = compact.NewDownsampleProgressCalculator(unRegisterer)
ds = compact.NewDownsampleProgressCalculator(reg)
}

return runutil.Repeat(5*time.Minute, ctx.Done(), func() error {
Expand All @@ -481,10 +479,8 @@ func runCompact(
return errors.Wrapf(err, "could not group original metadata")
}

for _, group := range groups {
ps.CompactProgressMetrics.NumberOfCompactionRuns.WithLabelValues(group.Key())
ps.CompactProgressMetrics.NumberOfCompactionBlocks.WithLabelValues(group.Key())
}
ps.CompactProgressMetrics.NumberOfCompactionRuns.Reset()
ps.CompactProgressMetrics.NumberOfCompactionBlocks.Reset()

if err = ps.ProgressCalculate(ctx, groups); err != nil {
return errors.Wrapf(err, "could not calculate compaction progress")
Expand All @@ -495,9 +491,7 @@ func runCompact(
if err != nil {
return errors.Wrapf(err, "could not group original metadata into downsample groups")
}
for _, group := range groups {
ds.DownsampleProgressMetrics.NumberOfBlocksDownsampled.WithLabelValues(group.Key())
}
ds.DownsampleProgressMetrics.NumberOfBlocksDownsampled.Reset()
if err := ds.ProgressCalculate(ctx, groups); err != nil {
return errors.Wrapf(err, "could not calculate downsampling progress")
}
Expand Down Expand Up @@ -646,7 +640,7 @@ type compactConfig struct {
}

func (cc *compactConfig) registerFlag(cmd extkingpin.FlagClause) {
cmd.Flag("progress-metrics", "Enables the progress metrics, indicating the progress of compaction and downsampling").Default("false").BoolVar(&cc.compactionProgressMetrics)
cmd.Flag("progress-metrics", "Enables the progress metrics, indicating the progress of compaction and downsampling").Default("true").BoolVar(&cc.compactionProgressMetrics)

cmd.Flag("debug.halt-on-error", "Halt the process if a critical compaction error is detected.").
Hidden().Default("true").BoolVar(&cc.haltOnError)
Expand Down

0 comments on commit 0660dc2

Please sign in to comment.