mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-24 13:46:36 +00:00
mscluster: merge multiple collector into one (Click here for more information) (#1585)
This commit is contained in:
@@ -5,7 +5,6 @@ package exchange
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
@@ -78,8 +77,6 @@ type Collector struct {
|
||||
unreachableQueueLength *prometheus.Desc
|
||||
userCount *prometheus.Desc
|
||||
yieldedTasks *prometheus.Desc
|
||||
|
||||
enabledCollectors []string
|
||||
}
|
||||
|
||||
func New(config *Config) *Collector {
|
||||
@@ -229,18 +226,6 @@ func (c *Collector) Build(_ log.Logger) error {
|
||||
c.syncCommandsPerSec = desc("activesync_sync_cmds_total", "Number of sync commands processed per second. Clients use this command to synchronize items within a folder")
|
||||
c.activeUserCountMapiHttpEmsMDB = desc("mapihttp_emsmdb_active_user_count", "Number of unique outlook users that have shown some kind of activity in the last 2 minutes")
|
||||
|
||||
c.enabledCollectors = make([]string, 0, len(ConfigDefaults.CollectorsEnabled))
|
||||
|
||||
for _, collectorName := range c.config.CollectorsEnabled {
|
||||
if !slices.Contains(ConfigDefaults.CollectorsEnabled, collectorName) {
|
||||
return fmt.Errorf("unknown exchange collector: %s", collectorName)
|
||||
}
|
||||
|
||||
c.enabledCollectors = append(c.enabledCollectors, collectorName)
|
||||
}
|
||||
|
||||
c.enabledCollectors = slices.Clip(c.enabledCollectors)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -260,7 +245,7 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger log.Logger, ch chan
|
||||
"MapiHttpEmsmdb": c.collectMapiHttpEmsmdb,
|
||||
}
|
||||
|
||||
for _, collectorName := range c.enabledCollectors {
|
||||
for _, collectorName := range c.config.CollectorsEnabled {
|
||||
if err := collectorFuncs[collectorName](ctx, logger, ch); err != nil {
|
||||
_ = level.Error(logger).Log("msg", "Error in "+collectorName, "err", err)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user