fix(service,iis,docs): flag error names, IIS help typo, mixin tooling and log.file default (#2732)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-15 21:24:06 +00:00
committed by GitHub
parent 379b1553bd
commit 34738679a1
6 changed files with 46 additions and 10 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
c.info = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "info"),
"ISS information",
"IIS information",
[]string{},
prometheus.Labels{"version": fmt.Sprintf("%d.%d", c.iisVersion.major, c.iisVersion.minor)},
)
+3 -3
View File
@@ -152,7 +152,7 @@ func NewWithFlags(app *kingpin.Application) *Collector {
app.Flag(
"collector.service.include",
"Regexp of service to include. Process name (not the display name!) must both match include and not match exclude to be included.",
"Regexp of service to include. Service name (not the display name!) must both match include and not match exclude to be included.",
).Default(".+").StringVar(&serviceInclude)
app.Flag(
@@ -165,12 +165,12 @@ func NewWithFlags(app *kingpin.Application) *Collector {
c.config.ServiceExclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", serviceExclude))
if err != nil {
return fmt.Errorf("collector.process.exclude: %w", err)
return fmt.Errorf("collector.service.exclude: %w", err)
}
c.config.ServiceInclude, err = regexp.Compile(fmt.Sprintf("^(?:%s)$", serviceInclude))
if err != nil {
return fmt.Errorf("collector.process.include: %w", err)
return fmt.Errorf("collector.service.include: %w", err)
}
c.config.ServiceStartModeInclude = strings.Split(serviceStartModeInclude, ",")
@@ -20,8 +20,10 @@ package service_test
import (
"testing"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/collector/service"
"github.com/prometheus-community/windows_exporter/internal/utils/testutils"
"github.com/stretchr/testify/require"
)
func BenchmarkCollector(b *testing.B) {
@@ -31,3 +33,19 @@ func BenchmarkCollector(b *testing.B) {
func TestCollector(t *testing.T) {
testutils.TestCollector(t, service.New, nil)
}
func TestNewWithFlagsReportsRegexpFlagName(t *testing.T) {
t.Parallel()
for _, flagName := range []string{"collector.service.exclude", "collector.service.include"} {
t.Run(flagName, func(t *testing.T) {
t.Parallel()
app := kingpin.New("test", "")
service.NewWithFlags(app)
_, err := app.Parse([]string{"--" + flagName + "=("})
require.ErrorContains(t, err, flagName+":")
})
}
}