collector: publish base units and _total counter names (#2743)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-16 10:48:26 +02:00
committed by GitHub
parent dc8092f46d
commit 3fb18521f6
131 changed files with 1674 additions and 1459 deletions
+3 -3
View File
@@ -151,8 +151,8 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
nil,
)
c.printerJobCount = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "job_count"),
"Number of jobs processed by the printer since the last reset",
prometheus.BuildFQName(types.Namespace, Name, "jobs"),
"Number of jobs in the queue of the printer",
[]string{"printer"},
nil,
)
@@ -190,7 +190,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric, _ time.Duration) error
// Win32_Printer JobCountSinceLastReset is PRINTER_INFO_2.cJobs, the number of queued jobs.
ch <- prometheus.MustNewConstMetric(
c.printerJobCount,
prometheus.CounterValue,
prometheus.GaugeValue,
float64(printer.Jobs),
printer.Name,
)
+1 -1
View File
@@ -35,7 +35,7 @@ func BenchmarkCollector(b *testing.B) {
func TestCollector(t *testing.T) {
metrics := testutils.TestCollector(t, printer.New, nil)
testutils.RequireFixtureMetric(t, metrics, printer.Name, "windows_printer_job_count", prometheus.Labels{"printer": "CIPrinter"})
testutils.RequireFixtureMetric(t, metrics, printer.Name, "windows_printer_jobs", prometheus.Labels{"printer": "CIPrinter"})
}
// TestCollectorWithoutMISession checks that the collector does not depend on WMI.