Skip to content

Commit

Permalink
attempt at fixing concurrent map access lower in the Collect()
Browse files Browse the repository at this point in the history
It could be that in theory the metics return early, while the scrape is still
runing. When Prometheus has a low scrape interval, this trigger concurrent map
access for the `ServiceCurveExporter` map in the `class.go`.

By removing the concurreny, we might slow down the exporter, but can confirm that
the concurrent access is causing issues. Otherwise this might be an issue deeper
down in the logic (and I have a bad feeling it is).
  • Loading branch information
fbegyn committed Mar 31, 2024
1 parent e385197 commit 06f8463
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tccollector

import (
"log/slog"
"sync"

"github.com/jsimonetti/rtnetlink"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -55,14 +54,9 @@ func (t TcCollector) Describe(ch chan<- *prometheus.Desc) {

// Collect fetches and updates the data the collector is exporting
func (t TcCollector) Collect(ch chan<- prometheus.Metric) {
wg := sync.WaitGroup{}
wg.Add(len(t.Collectors))
t.logger.Info("processing scrape")
for _, coll := range t.Collectors {
go func(c prometheus.Collector) {
c.Collect(ch)
wg.Done()
}(coll)
coll.Collect(ch)
}
wg.Wait()
t.logger.Info("scrape complete")
}

0 comments on commit 06f8463

Please sign in to comment.