Skip to content
Snippets Groups Projects
Commit 3c1b6025 authored by Joris Beckers's avatar Joris Beckers Committed by Oliver
Browse files

Split key-value line on first colon (#243)

* Split key-value line on first colon

* Add IPv6 test to connected slave test
parent e3f43cfe
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -624,11 +624,7 @@ func (e *Exporter) extractInfoMetrics(info, addr string, alias string, scrapes c
continue
}
 
split := strings.Split(line, ":")
if len(split) != 2 {
continue
}
split := strings.SplitN(line, ":", 2)
fieldKey := split[0]
fieldValue := split[1]
 
Loading
Loading
Loading
Loading
@@ -585,6 +585,7 @@ type slaveData struct {
func TestParseConnectedSlaveString(t *testing.T) {
tsts := []slaveData{
{k: "slave0", v: "ip=10.254.11.1,port=6379,state=online,offset=1751844676,lag=0", offset: 1751844676, ip: "10.254.11.1", port: "6379", state: "online", ok: true, lag: 0},
{k: "slave0", v: "ip=2a00:1450:400e:808::200e,port=6379,state=online,offset=1751844676,lag=0", offset: 1751844676, ip: "2a00:1450:400e:808::200e", port: "6379", state: "online", ok: true, lag: 0},
{k: "slave1", v: "offset=1,lag=0", offset: 1, ok: true},
{k: "slave1", v: "offset=1", offset: 1, ok: true, lag: -1},
{k: "slave2", v: "ip=1.2.3.4,state=online,offset=123,lag=42", offset: 123, ip: "1.2.3.4", state: "online", ok: true, lag: 42},
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