Skip to content

Commit 7474248

Browse files
committed
fix: add missing metrics dropper
1 parent e9c66b0 commit 7474248

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Companion/exporter/inventory_collector_storage.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,43 @@ package exporter
33
import (
44
"log"
55
"strconv"
6+
7+
"github.com/prometheus/client_golang/prometheus"
68
)
79

810
type StorageInventoryCollector struct {
9-
endpoint string
11+
endpoint string
12+
metricsDropper *MetricsDropper
1013
}
1114

1215
func NewStorageInventoryCollector(endpoint string) *StorageInventoryCollector {
1316
return &StorageInventoryCollector{
1417
endpoint: endpoint,
18+
metricsDropper: NewMetricsDropper(
19+
StorageInventory,
20+
StorageInventoryMax,
21+
),
1522
}
1623
}
1724

1825
func (c *StorageInventoryCollector) Collect(frmAddress string, sessionName string) {
1926
details := []ContainerDetail{}
2027
err := retrieveData(frmAddress+c.endpoint, &details)
2128
if err != nil {
29+
c.metricsDropper.DropStaleMetricLabels()
2230
log.Printf("error reading inventory statistics from FRM: %s\n", err)
2331
return
2432
}
2533

2634
for _, detail := range details {
35+
c.metricsDropper.CacheFreshMetricLabel(prometheus.Labels{
36+
"url": frmAddress,
37+
"session_name": sessionName,
38+
"container_name": detail.Name,
39+
"x": strconv.FormatFloat(detail.Location.X, 'f', -1, 64),
40+
"y": strconv.FormatFloat(detail.Location.Y, 'f', -1, 64),
41+
"z": strconv.FormatFloat(detail.Location.Z, 'f', -1, 64),
42+
})
2743
for _, item := range detail.Inventory {
2844
StorageInventory.WithLabelValues(
2945
item.Name,
@@ -36,6 +52,7 @@ func (c *StorageInventoryCollector) Collect(frmAddress string, sessionName strin
3652
).Set(float64(item.Amount))
3753
}
3854
}
55+
c.metricsDropper.DropStaleMetricLabels()
3956
}
4057

4158
func (c *StorageInventoryCollector) DropCache() {}

0 commit comments

Comments
 (0)