Skip to content

Commit 7c49531

Browse files
committed
Revert "Rename unitInclude* and unitExclude* variables to systemdInclude* and"
This reverts commit 15d6137. Signed-off-by: Conall O'Brien <[email protected]>
1 parent 15d6137 commit 7c49531

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

collector/systemd_linux.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ const (
4242
)
4343

4444
var (
45-
systemdIncludeSet bool
46-
systemdInclude = kingpin.Flag("collector.systemd.unit-include", "Regexp of systemd units to include. Units must both match include and not match exclude to be included.").Default(".+").PreAction(func(c *kingpin.ParseContext) error {
47-
systemdIncludeSet = true
45+
unitIncludeSet bool
46+
unitInclude = kingpin.Flag("collector.systemd.unit-include", "Regexp of systemd units to include. Units must both match include and not match exclude to be included.").Default(".+").PreAction(func(c *kingpin.ParseContext) error {
47+
unitIncludeSet = true
4848
return nil
4949
}).String()
5050
oldUnitInclude = kingpin.Flag("collector.systemd.unit-whitelist", "DEPRECATED: Use --collector.systemd.unit-include").Hidden().String()
51-
systemdExcludeSet bool
52-
systemdExclude = kingpin.Flag("collector.systemd.unit-exclude", "Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.").Default(".+\\.(automount|device|mount|scope|slice)").PreAction(func(c *kingpin.ParseContext) error {
53-
systemdExcludeSet = true
51+
unitExcludeSet bool
52+
unitExclude = kingpin.Flag("collector.systemd.unit-exclude", "Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.").Default(".+\\.(automount|device|mount|scope|slice)").PreAction(func(c *kingpin.ParseContext) error {
53+
unitExcludeSet = true
5454
return nil
5555
}).String()
5656
oldUnitExclude = kingpin.Flag("collector.systemd.unit-blacklist", "DEPRECATED: Use collector.systemd.unit-exclude").Hidden().String()
@@ -75,8 +75,8 @@ type systemdCollector struct {
7575
socketCurrentConnectionsDesc *prometheus.Desc
7676
socketRefusedConnectionsDesc *prometheus.Desc
7777
systemdVersionDesc *prometheus.Desc
78-
systemdIncludePattern *regexp.Regexp
79-
systemdExcludePattern *regexp.Regexp
78+
unitIncludePattern *regexp.Regexp
79+
unitExcludePattern *regexp.Regexp
8080
logger log.Logger
8181
}
8282

@@ -134,25 +134,25 @@ func NewSystemdCollector(logger log.Logger) (Collector, error) {
134134
"Detected systemd version", []string{"version"}, nil)
135135

136136
if *oldUnitExclude != "" {
137-
if !systemdExcludeSet {
137+
if !unitExcludeSet {
138138
level.Warn(logger).Log("msg", "--collector.systemd.unit-blacklist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-exclude")
139-
*systemdExclude = *oldUnitExclude
139+
*unitExclude = *oldUnitExclude
140140
} else {
141141
return nil, errors.New("--collector.systemd.unit-blacklist and --collector.systemd.unit-exclude are mutually exclusive")
142142
}
143143
}
144144
if *oldUnitInclude != "" {
145-
if !systemdIncludeSet {
145+
if !unitIncludeSet {
146146
level.Warn(logger).Log("msg", "--collector.systemd.unit-whitelist is DEPRECATED and will be removed in 2.0.0, use --collector.systemd.unit-include")
147-
*systemdInclude = *oldUnitInclude
147+
*unitInclude = *oldUnitInclude
148148
} else {
149149
return nil, errors.New("--collector.systemd.unit-whitelist and --collector.systemd.unit-include are mutually exclusive")
150150
}
151151
}
152-
level.Info(logger).Log("msg", "Parsed flag --collector.systemd.unit-include", "flag", *systemdInclude)
153-
systemdIncludePattern := regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *systemdInclude))
154-
level.Info(logger).Log("msg", "Parsed flag --collector.systemd.unit-exclude", "flag", *systemdExclude)
155-
systemdExcludePattern := regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *systemdExclude))
152+
level.Info(logger).Log("msg", "Parsed flag --collector.systemd.unit-include", "flag", *unitInclude)
153+
unitIncludePattern := regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *unitInclude))
154+
level.Info(logger).Log("msg", "Parsed flag --collector.systemd.unit-exclude", "flag", *unitExclude)
155+
unitExcludePattern := regexp.MustCompile(fmt.Sprintf("^(?:%s)$", *unitExclude))
156156

157157
return &systemdCollector{
158158
unitDesc: unitDesc,
@@ -167,8 +167,8 @@ func NewSystemdCollector(logger log.Logger) (Collector, error) {
167167
socketCurrentConnectionsDesc: socketCurrentConnectionsDesc,
168168
socketRefusedConnectionsDesc: socketRefusedConnectionsDesc,
169169
systemdVersionDesc: systemdVersionDesc,
170-
systemdIncludePattern: systemdIncludePattern,
171-
systemdExcludePattern: systemdExcludePattern,
170+
unitIncludePattern: unitIncludePattern,
171+
unitExcludePattern: unitExcludePattern,
172172
logger: logger,
173173
}, nil
174174
}
@@ -206,7 +206,7 @@ func (c *systemdCollector) Update(ch chan<- prometheus.Metric) error {
206206
level.Debug(c.logger).Log("msg", "collectSummaryMetrics took", "duration_seconds", time.Since(begin).Seconds())
207207

208208
begin = time.Now()
209-
units := filterUnits(allUnits, c.systemdIncludePattern, c.systemdExcludePattern, c.logger)
209+
units := filterUnits(allUnits, c.unitIncludePattern, c.unitExcludePattern, c.logger)
210210
level.Debug(c.logger).Log("msg", "filterUnits took", "duration_seconds", time.Since(begin).Seconds())
211211

212212
var wg sync.WaitGroup

collector/systemd_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestSystemdIgnoreFilterDefaultKeepsAll(t *testing.T) {
106106
}
107107
fixtures := getUnitListFixtures()
108108
collector := c.(*systemdCollector)
109-
filtered := filterUnits(fixtures[0], collector.systemdIncludePattern, collector.systemdExcludePattern, logger)
109+
filtered := filterUnits(fixtures[0], collector.unitIncludePattern, collector.unitExcludePattern, logger)
110110
// Adjust fixtures by 3 "not-found" units.
111111
if len(filtered) != len(fixtures[0])-3 {
112112
t.Error("Default filters removed units")

0 commit comments

Comments
 (0)