chore: pass context aware logger to collectors (#1582)

This commit is contained in:
Jan-Otto Kröpke
2024-08-24 19:14:38 +02:00
committed by GitHub
parent fbead0fb79
commit 89c832feb0
65 changed files with 876 additions and 1164 deletions

View File

@@ -114,7 +114,7 @@ func (coll *Prometheus) Collect(ch chan<- prometheus.Metric) {
for name, c := range coll.collectors.collectors {
go func(name string, c Collector) {
defer wg.Done()
outcome := coll.execute(name, c, scrapeContext, metricsBuffer)
outcome := coll.execute(coll.logger, name, c, scrapeContext, metricsBuffer)
l.Lock()
if !finished {
collectorOutcomes[name] = outcome
@@ -171,9 +171,9 @@ func (coll *Prometheus) Collect(ch chan<- prometheus.Metric) {
l.Unlock()
}
func (coll *Prometheus) execute(name string, c Collector, ctx *types.ScrapeContext, ch chan<- prometheus.Metric) collectorOutcome {
func (coll *Prometheus) execute(logger log.Logger, name string, c Collector, ctx *types.ScrapeContext, ch chan<- prometheus.Metric) collectorOutcome {
t := time.Now()
err := c.Collect(ctx, ch)
err := c.Collect(ctx, logger, ch)
duration := time.Since(t).Seconds()
ch <- prometheus.MustNewConstMetric(
coll.scrapeDurationDesc,