mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-08 03:26:35 +00:00
feat: Tolerate collector failures (#1769)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -16,8 +16,8 @@
|
||||
package msmq
|
||||
|
||||
const (
|
||||
BytesInJournalQueue = "Bytes in Journal Queue"
|
||||
BytesInQueue = "Bytes in Queue"
|
||||
MessagesInJournalQueue = "Messages in Journal Queue"
|
||||
MessagesInQueue = "Messages in Queue"
|
||||
bytesInJournalQueue = "Bytes in Journal Queue"
|
||||
bytesInQueue = "Bytes in Queue"
|
||||
messagesInJournalQueue = "Messages in Journal Queue"
|
||||
messagesInQueue = "Messages in Queue"
|
||||
)
|
||||
|
||||
@@ -30,6 +30,7 @@ const Name = "msmq"
|
||||
|
||||
type Config struct{}
|
||||
|
||||
//nolint:gochecknoglobals
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// A Collector is a Prometheus Collector for WMI Win32_PerfRawData_MSMQ_MSMQQueue metrics.
|
||||
@@ -75,10 +76,10 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
|
||||
var err error
|
||||
|
||||
c.perfDataCollector, err = perfdata.NewCollector("MSMQ Queue", perfdata.InstancesAll, []string{
|
||||
BytesInJournalQueue,
|
||||
BytesInQueue,
|
||||
MessagesInJournalQueue,
|
||||
MessagesInQueue,
|
||||
bytesInJournalQueue,
|
||||
bytesInQueue,
|
||||
messagesInJournalQueue,
|
||||
messagesInQueue,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create MSMQ Queue collector: %w", err)
|
||||
@@ -124,28 +125,28 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bytesInJournalQueue,
|
||||
prometheus.GaugeValue,
|
||||
data[BytesInJournalQueue].FirstValue,
|
||||
data[bytesInJournalQueue].FirstValue,
|
||||
name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.bytesInQueue,
|
||||
prometheus.GaugeValue,
|
||||
data[BytesInQueue].FirstValue,
|
||||
data[bytesInQueue].FirstValue,
|
||||
name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.messagesInJournalQueue,
|
||||
prometheus.GaugeValue,
|
||||
data[MessagesInJournalQueue].FirstValue,
|
||||
data[messagesInJournalQueue].FirstValue,
|
||||
name,
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.messagesInQueue,
|
||||
prometheus.GaugeValue,
|
||||
data[MessagesInQueue].FirstValue,
|
||||
data[messagesInQueue].FirstValue,
|
||||
name,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user