collector: Add disable flag (#2165)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Jan-Otto Kröpke
2025-08-07 08:58:29 +02:00
committed by GitHub
parent 0e85959a4d
commit 930130f58a
2 changed files with 17 additions and 0 deletions

View File

@@ -198,6 +198,15 @@ func (c *Collection) Enable(enabledCollectors []string) error {
return nil
}
// Disable removes all collectors that are listed in disabledCollectors.
func (c *Collection) Disable(disabledCollectors []string) {
for name := range c.collectors {
if slices.Contains(disabledCollectors, name) {
delete(c.collectors, name)
}
}
}
// Build To be called by the exporter for collector initialization.
// Instead, fail fast, it will try to build all collectors and return all errors.
// errors are joined with errors.Join.