mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-03 17:16:37 +00:00
chore: pass context aware logger to collectors (#1582)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user