Skip to content

Commit

Permalink
feat: Track when builders are doing work with a gauge (#13570)
Browse files Browse the repository at this point in the history
  • Loading branch information
salvacorts authored Jul 18, 2024
1 parent bd1d6a7 commit 0029d46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/bloombuild/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (b *Builder) builderLoop(c protos.PlannerForBuilder_BuilderLoopClient) erro
return fmt.Errorf("failed to receive task from planner: %w", err)
}

b.metrics.processingTask.Set(1)
b.metrics.taskStarted.Inc()
start := time.Now()

Expand All @@ -212,8 +213,11 @@ func (b *Builder) builderLoop(c protos.PlannerForBuilder_BuilderLoopClient) erro

b.logTaskCompleted(task, newMetas, err, start)
if err = b.notifyTaskCompletedToPlanner(c, task, newMetas, err); err != nil {
b.metrics.processingTask.Set(0)
return fmt.Errorf("failed to notify task completion to planner: %w", err)
}

b.metrics.processingTask.Set(0)
}

level.Debug(b.logger).Log("msg", "builder loop stopped")
Expand Down
9 changes: 8 additions & 1 deletion pkg/bloombuild/builder/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const (
)

type Metrics struct {
running prometheus.Gauge
running prometheus.Gauge
processingTask prometheus.Gauge

taskStarted prometheus.Counter
taskCompleted *prometheus.CounterVec
Expand All @@ -38,6 +39,12 @@ func NewMetrics(r prometheus.Registerer) *Metrics {
Name: "running",
Help: "Value will be 1 if the bloom builder is currently running on this instance",
}),
processingTask: promauto.With(r).NewGauge(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: metricsSubsystem,
Name: "processing_task",
Help: "Value will be 1 if the bloom builder is currently processing a task",
}),

taskStarted: promauto.With(r).NewCounter(prometheus.CounterOpts{
Namespace: metricsNamespace,
Expand Down

0 comments on commit 0029d46

Please sign in to comment.