mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-31 23:06:36 +00:00
mi: make timeout configurable for build functions (#2377)
This commit is contained in:
@@ -136,7 +136,7 @@ func (c *Collection) collectCollector(ch chan<- prometheus.Metric, logger *slog.
|
||||
close(bufCh)
|
||||
}()
|
||||
|
||||
errCh <- collector.Collect(bufCh)
|
||||
errCh <- collector.Collect(bufCh, maxScrapeDuration)
|
||||
}()
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
@@ -244,6 +244,7 @@ func (c *Collection) Build(ctx context.Context, logger *slog.Logger) error {
|
||||
errors.Is(err, registry.ErrNotExist) ||
|
||||
errors.Is(err, pdh.NewPdhError(pdh.CstatusNoObject)) ||
|
||||
errors.Is(err, pdh.NewPdhError(pdh.CstatusNoCounter)) ||
|
||||
errors.Is(err, mi.MI_RESULT_INVALID_OPERATION_TIMEOUT) ||
|
||||
errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE) {
|
||||
logger.LogAttrs(ctx, slog.LevelWarn, "couldn't initialize collector", slog.Any("err", err))
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ type Collector interface {
|
||||
// Build build the collector
|
||||
Build(logger *slog.Logger, miSession *mi.Session) error
|
||||
// Collect Get new metrics and expose them via prometheus registry.
|
||||
Collect(ch chan<- prometheus.Metric) (err error)
|
||||
Collect(ch chan<- prometheus.Metric, maxScrapeDuration time.Duration) (err error)
|
||||
// Close closes the collector
|
||||
Close() error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user