Skip to content

Commit aaa8987

Browse files
committed
Fixed collectDetailMetricsFromReader to handle a row with an empty user value.
1 parent d0015ce commit aaa8987

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

dovecot_exporter.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func collectDetailMetricsFromReader(reader io.Reader, scope string, ch chan<- pr
123123
if !scanner.Scan() {
124124
return fmt.Errorf("Failed to extract columns from input")
125125
}
126-
columnNames := strings.Fields(scanner.Text())
126+
columnNames := strings.Split(scanner.Text(), "\t")
127127
if len(columnNames) < 2 {
128128
return fmt.Errorf("Input does not provide any columns")
129129
}
@@ -144,10 +144,13 @@ func collectDetailMetricsFromReader(reader io.Reader, scope string, ch chan<- pr
144144
break
145145
}
146146

147-
values := strings.Fields(row)
147+
values := strings.Split(row, "\t")
148148
if len(values) != len(columns)+1 {
149149
return fmt.Errorf("error while parsing rows: value count does not match column count")
150150
}
151+
if values[0] == "" {
152+
values[0] = "empty_user"
153+
}
151154

152155
for i, value := range values[1:] {
153156
f, err := strconv.ParseFloat(value, 64)

0 commit comments

Comments
 (0)