@@ -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