Skip to content
Snippets Groups Projects
Commit 9a15761a authored by Abonyi Bence Péter's avatar Abonyi Bence Péter :scream_cat:
Browse files

corrected wg.Done is now deferred

parent 610ae3fe
No related branches found
No related tags found
No related merge requests found
Pipeline #52121 passed
......@@ -106,12 +106,14 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
}
func (e *Exporter) collectItems(ch chan<- prometheus.Metric, wg *sync.WaitGroup) {
defer wg.Done()
res, err := http.Get("http://localhost:8080/api/items")
if err != nil {
e.logger.Println("exporter collecting items failed: ", err)
return
}
var items []Item
if err := json.NewDecoder(res.Body).Decode(&items); err != nil {
if err = json.NewDecoder(res.Body).Decode(&items); err != nil {
log.Println(err)
return
}
......@@ -133,9 +135,8 @@ func (e *Exporter) collectItems(ch chan<- prometheus.Metric, wg *sync.WaitGroup)
}
e.itemsAvailable.Collect(ch)
e.itemsTotal.Collect(ch)
wg.Done()
}
func (e *Exporter) collectPurchases(ch chan<- prometheus.Metric, wg *sync.WaitGroup) {
wg.Done()
defer wg.Done()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment