Skip to content
Snippets Groups Projects
Commit b60ce381 authored by Oliver's avatar Oliver
Browse files

fix replication metrics handling

parent 82725698
No related branches found
No related tags found
No related merge requests found
Loading
@@ -560,7 +560,7 @@ func (e *Exporter) handleMetricsCommandStats(addr string, alias string, fieldKey
Loading
@@ -560,7 +560,7 @@ func (e *Exporter) handleMetricsCommandStats(addr string, alias string, fieldKey
e.metrics["commands_duration_seconds_total"].WithLabelValues(addr, alias, cmd).Set(usecTotal / 1e6) e.metrics["commands_duration_seconds_total"].WithLabelValues(addr, alias, cmd).Set(usecTotal / 1e6)
} }
   
func (e *Exporter) handleMetricsReplication(addr string, alias string, fieldKey string, fieldValue string) { func (e *Exporter) handleMetricsReplication(addr string, alias string, fieldKey string, fieldValue string) bool {
e.metricsMtx.RLock() e.metricsMtx.RLock()
defer e.metricsMtx.RUnlock() defer e.metricsMtx.RUnlock()
   
Loading
@@ -571,7 +571,7 @@ func (e *Exporter) handleMetricsReplication(addr string, alias string, fieldKey
Loading
@@ -571,7 +571,7 @@ func (e *Exporter) handleMetricsReplication(addr string, alias string, fieldKey
} else { } else {
e.metrics["master_link_up"].WithLabelValues(addr, alias).Set(0) e.metrics["master_link_up"].WithLabelValues(addr, alias).Set(0)
} }
return return true
} }
   
// not a slave, try extracting master metrics // not a slave, try extracting master metrics
Loading
@@ -593,7 +593,10 @@ func (e *Exporter) handleMetricsReplication(addr string, alias string, fieldKey
Loading
@@ -593,7 +593,10 @@ func (e *Exporter) handleMetricsReplication(addr string, alias string, fieldKey
slaveState, slaveState,
).Set(lag) ).Set(lag)
} }
return true
} }
return false
} }
   
func (e *Exporter) handleMetricsServer(addr string, alias string, fieldKey string, fieldValue string) { func (e *Exporter) handleMetricsServer(addr string, alias string, fieldKey string, fieldValue string) {
Loading
@@ -641,8 +644,9 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
Loading
@@ -641,8 +644,9 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
switch fieldClass { switch fieldClass {
   
case "Replication": case "Replication":
e.handleMetricsReplication(addr, alias, fieldKey, fieldValue) if ok := e.handleMetricsReplication(addr, alias, fieldKey, fieldValue); ok {
continue continue
}
   
case "Server": case "Server":
e.handleMetricsServer(addr, alias, fieldKey, fieldValue) e.handleMetricsServer(addr, alias, fieldKey, fieldValue)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment