rename deprecated collector functions

This commit is contained in:
Hector 2021-08-30 16:56:09 +01:00
parent 2ff6d64007
commit e60d822fa2

View File

@ -117,11 +117,11 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
func (e *Exporter) Collect(ch chan<- prometheus.Metric) { func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
if e.db != nil { if e.db != nil {
e.collectBadIpsPerJailMetrics(ch) e.collectDeprecatedBadIpsPerJailMetrics(ch)
e.collectBannedIpsPerJailMetrics(ch) e.collectDeprecatedBannedIpsPerJailMetrics(ch)
e.collectEnabledJailMetrics(ch) e.collectDeprecatedEnabledJailMetrics(ch)
e.collectUpMetric(ch) e.collectDeprecatedUpMetric(ch)
e.collectErrorCountMetric(ch) e.collectDeprecatedErrorCountMetric(ch)
} }
if e.socketPath != "" { if e.socketPath != "" {
s, err := socket.ConnectToSocket(e.socketPath) s, err := socket.ConnectToSocket(e.socketPath)
@ -136,10 +136,10 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
e.collectJailMetrics(ch, s) e.collectJailMetrics(ch, s)
} }
} }
e.collectErrorCountMetricNew(ch) e.collectErrorCountMetric(ch)
} }
func (e *Exporter) collectUpMetric(ch chan<- prometheus.Metric) { func (e *Exporter) collectDeprecatedUpMetric(ch chan<- prometheus.Metric) {
var upMetricValue float64 = 1 var upMetricValue float64 = 1
if e.lastError != nil { if e.lastError != nil {
upMetricValue = 0 upMetricValue = 0
@ -149,13 +149,13 @@ func (e *Exporter) collectUpMetric(ch chan<- prometheus.Metric) {
) )
} }
func (e *Exporter) collectErrorCountMetric(ch chan<- prometheus.Metric) { func (e *Exporter) collectDeprecatedErrorCountMetric(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
deprecatedMetricErrorCount, prometheus.CounterValue, float64(e.dbErrorCount), "db", deprecatedMetricErrorCount, prometheus.CounterValue, float64(e.dbErrorCount), "db",
) )
} }
func (e *Exporter) collectBadIpsPerJailMetrics(ch chan<- prometheus.Metric) { func (e *Exporter) collectDeprecatedBadIpsPerJailMetrics(ch chan<- prometheus.Metric) {
jailNameToCountMap, err := e.db.CountBadIpsPerJail() jailNameToCountMap, err := e.db.CountBadIpsPerJail()
e.lastError = err e.lastError = err
@ -171,7 +171,7 @@ func (e *Exporter) collectBadIpsPerJailMetrics(ch chan<- prometheus.Metric) {
} }
} }
func (e *Exporter) collectBannedIpsPerJailMetrics(ch chan<- prometheus.Metric) { func (e *Exporter) collectDeprecatedBannedIpsPerJailMetrics(ch chan<- prometheus.Metric) {
jailNameToCountMap, err := e.db.CountBannedIpsPerJail() jailNameToCountMap, err := e.db.CountBannedIpsPerJail()
e.lastError = err e.lastError = err
@ -187,7 +187,7 @@ func (e *Exporter) collectBannedIpsPerJailMetrics(ch chan<- prometheus.Metric) {
} }
} }
func (e *Exporter) collectEnabledJailMetrics(ch chan<- prometheus.Metric) { func (e *Exporter) collectDeprecatedEnabledJailMetrics(ch chan<- prometheus.Metric) {
jailNameToEnabledMap, err := e.db.JailNameToEnabledValue() jailNameToEnabledMap, err := e.db.JailNameToEnabledValue()
e.lastError = err e.lastError = err
@ -203,15 +203,15 @@ func (e *Exporter) collectEnabledJailMetrics(ch chan<- prometheus.Metric) {
} }
} }
func (e *Exporter) collectErrorCountMetricNew(ch chan<- prometheus.Metric) { func (e *Exporter) collectErrorCountMetric(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
metricErrorCount, prometheus.CounterValue, float64(e.dbErrorCount), "db", metricErrorCount, prometheus.CounterValue, float64(e.dbErrorCount), "db",
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
metricErrorCountNew, prometheus.CounterValue, float64(e.socketConnectionErrorCount), "socket_conn", metricErrorCount, prometheus.CounterValue, float64(e.socketConnectionErrorCount), "socket_conn",
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
metricErrorCountNew, prometheus.CounterValue, float64(e.socketRequestErrorCount), "socket_req", metricErrorCount, prometheus.CounterValue, float64(e.socketRequestErrorCount), "socket_req",
) )
} }