UDP drops should be a counter, not a gauge.

I think it makes sense for "drops" to sit alongside the queue length
gauges in prom stats because they are all neighbors in procfs (source
of these stats).

Moreover, in reading the commit log message for the original creating
work for udp_queues, I think there may have been some misreading or
confusion between the word "state" and the common short-form of
"stats" to mean "statistics".  The original author "chose the name
'udp_queue' instead of 'udpstat' as UDP has no state"; I believe that
'udpstat' might actually be the more appropriate name.

Signed-off-by: Chris Cleeland <chris.cleeland@gmail.com>
This commit is contained in:
Chris Cleeland 2024-04-23 11:22:29 -05:00
parent 5a060c2780
commit 1a67c6224a

View file

@ -62,7 +62,7 @@ func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.TxQueueLength), "tx", "v4")
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s4.RxQueueLength), "rx", "v4")
if s4.Drops != nil {
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s4.Drops), "drops", "v4")
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.CounterValue, float64(*s4.Drops), "drops", "v4")
}
} else {
if errors.Is(errIPv4, os.ErrNotExist) {
@ -77,7 +77,7 @@ func (c *udpQueuesCollector) Update(ch chan<- prometheus.Metric) error {
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s6.TxQueueLength), "tx", "v6")
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(s6.RxQueueLength), "rx", "v6")
if s6.Drops != nil {
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.GaugeValue, float64(*s6.Drops), "drops", "v6")
ch <- prometheus.MustNewConstMetric(c.desc, prometheus.CounterValue, float64(*s6.Drops), "drops", "v6")
}
} else {
if errors.Is(errIPv6, os.ErrNotExist) {