Skip to content

Commit 8f4fbf0

Browse files
committed
dont use metric holder for antispam metrics
1 parent 43aea22 commit 8f4fbf0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pipeline/antispam/antispammer.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Antispammer struct {
2929

3030
// antispammer metrics
3131
activeMetric prometheus.Gauge
32-
banMetric metric.HeldGaugeVec
32+
banMetric *prometheus.GaugeVec
3333
exceptionMetric *prometheus.CounterVec
3434
}
3535

@@ -57,8 +57,6 @@ func NewAntispammer(o *Options) *Antispammer {
5757
zap.Duration("maintenance", o.MaintenanceInterval))
5858
}
5959

60-
banMetric := o.MetricsController.RegisterGaugeVec("antispam_banned", "Source is banned", "source_name")
61-
6260
a := &Antispammer{
6361
unbanIterations: o.UnbanIterations,
6462
threshold: o.Threshold,
@@ -69,7 +67,7 @@ func NewAntispammer(o *Options) *Antispammer {
6967
activeMetric: o.MetricsController.RegisterGauge("antispam_active",
7068
"Gauge indicates whether the antispam is enabled",
7169
),
72-
banMetric: o.MetricHolder.AddGaugeVec(banMetric),
70+
banMetric: o.MetricsController.RegisterGaugeVec("antispam_banned", "Source is banned", "source_name"),
7371
exceptionMetric: o.MetricsController.RegisterCounterVec("antispam_exceptions",
7472
"How many times an exception match with an event",
7573
"name",
@@ -157,6 +155,7 @@ func (a *Antispammer) Maintenance() {
157155

158156
if x == 0 {
159157
delete(a.sources, sourceID)
158+
a.banMetric.DeleteLabelValues(source.name)
160159
continue
161160
}
162161

0 commit comments

Comments
 (0)