Skip to content

Commit

Permalink
Followups #11154 (#11204)
Browse files Browse the repository at this point in the history
Addressing comments from #11154 after it was merged
  • Loading branch information
salvacorts authored Nov 10, 2023
1 parent 4248825 commit 54edb21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/bloomcompactor/bloomcompactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (c *Compactor) running(ctx context.Context) error {
case <-ticker.C:
c.metrics.compactionRunsStarted.Inc()
if err := c.runCompaction(ctx); err != nil {
c.metrics.compactionRunsErred.Inc()
c.metrics.compactionRunsFailed.Inc()
level.Error(c.logger).Log("msg", "failed to run compaction", "err", err)
continue
}
Expand Down
20 changes: 12 additions & 8 deletions pkg/bloomcompactor/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type Job struct {
seriesFP model.Fingerprint
chunks []index.ChunkMeta

// We compute them lazily.
from, through *model.Time
// We compute them lazily. Unset value is 0.
from, through model.Time
}

// NewJob returns a new compaction Job.
Expand Down Expand Up @@ -65,20 +65,24 @@ func (j *Job) IndexPath() string {
}

func (j *Job) From() model.Time {
if j.from == nil {
if j.from == 0 {
j.computeFromThrough()
}
return *j.from
return j.from
}

func (j *Job) Through() model.Time {
if j.through == nil {
if j.through == 0 {
j.computeFromThrough()
}
return *j.through
return j.through
}

func (j *Job) computeFromThrough() {
if len(j.chunks) == 0 {
return
}

minFrom := model.Latest
maxThrough := model.Earliest

Expand All @@ -92,6 +96,6 @@ func (j *Job) computeFromThrough() {
}
}

j.from = &minFrom
j.through = &maxThrough
j.from = minFrom
j.through = maxThrough
}
4 changes: 2 additions & 2 deletions pkg/bloomcompactor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
type metrics struct {
compactionRunsStarted prometheus.Counter
compactionRunsCompleted prometheus.Counter
compactionRunsErred prometheus.Counter
compactionRunsFailed prometheus.Counter
compactionRunDiscoveredTenants prometheus.Counter
compactionRunSkippedTenants prometheus.Counter
compactionRunSucceededTenants prometheus.Counter
Expand All @@ -39,7 +39,7 @@ func newMetrics(r prometheus.Registerer) *metrics {
Name: "runs_completed_total",
Help: "Total number of compactions completed successfully",
}),
compactionRunsErred: promauto.With(r).NewCounter(prometheus.CounterOpts{
compactionRunsFailed: promauto.With(r).NewCounter(prometheus.CounterOpts{
Namespace: metricsNamespace,
Subsystem: metricsSubsystem,
Name: "runs_failed_total",
Expand Down

0 comments on commit 54edb21

Please sign in to comment.