collector: add pprof labels to build and collection (#2562)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-09 01:17:00 +02:00
committed by GitHub
parent 210e98bdde
commit 0c0aab27e7
3 changed files with 18 additions and 8 deletions
+7 -4
View File
@@ -23,6 +23,7 @@ import (
"fmt"
"log/slog"
"runtime/debug"
"runtime/pprof"
"sync"
"time"
@@ -85,10 +86,12 @@ func (c *Collection) collectAll(ctx context.Context, ch chan<- prometheus.Metric
// timeout handling is done in the execute function
for name, metricsCollector := range c.collectors {
wg.Go(func() {
collectorStatusCh <- collectorStatus{
name: name,
statusCode: c.collectCollector(ctx, ch, logger, name, metricsCollector),
}
pprof.Do(ctx, pprof.Labels("collector", name), func(ctx context.Context) {
collectorStatusCh <- collectorStatus{
name: name,
statusCode: c.collectCollector(ctx, ch, logger, name, metricsCollector),
}
})
})
}
+8 -4
View File
@@ -23,6 +23,7 @@ import (
"fmt"
"log/slog"
"maps"
"runtime/pprof"
"slices"
gotime "time"
@@ -248,10 +249,13 @@ func (c *Collection) Build(ctx context.Context, logger *slog.Logger) error {
state := c.state.collector(name)
go func() {
resultCh <- buildResult{
name: collector.GetName(),
err: state.build(ctx, logger, miSession, collector),
}
// Workers started by Build inherit the collector's profiling label.
pprof.Do(ctx, pprof.Labels("collector", name), func(ctx context.Context) {
resultCh <- buildResult{
name: collector.GetName(),
err: state.build(ctx, logger, miSession, collector),
}
})
}()
}