Fix librato output support for uint and bool (#4151)
This commit is contained in:
parent
bb6b7aa4af
commit
93d17ec95e
|
@ -107,7 +107,6 @@ func (l *Librato) Write(metrics []telegraf.Metric) error {
|
||||||
for _, gauge := range gauges {
|
for _, gauge := range gauges {
|
||||||
tempGauges = append(tempGauges, gauge)
|
tempGauges = append(tempGauges, gauge)
|
||||||
log.Printf("D! Got a gauge: %v\n", gauge)
|
log.Printf("D! Got a gauge: %v\n", gauge)
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Printf("I! unable to build Gauge for %s, skipping\n", m.Name())
|
log.Printf("I! unable to build Gauge for %s, skipping\n", m.Name())
|
||||||
|
@ -234,16 +233,18 @@ func verifyValue(v interface{}) bool {
|
||||||
|
|
||||||
func (g *Gauge) setValue(v interface{}) error {
|
func (g *Gauge) setValue(v interface{}) error {
|
||||||
switch d := v.(type) {
|
switch d := v.(type) {
|
||||||
case int:
|
|
||||||
g.Value = float64(int(d))
|
|
||||||
case int32:
|
|
||||||
g.Value = float64(int32(d))
|
|
||||||
case int64:
|
case int64:
|
||||||
g.Value = float64(int64(d))
|
g.Value = float64(int64(d))
|
||||||
case float32:
|
case uint64:
|
||||||
g.Value = float64(d)
|
g.Value = float64(d)
|
||||||
case float64:
|
case float64:
|
||||||
g.Value = float64(d)
|
g.Value = float64(d)
|
||||||
|
case bool:
|
||||||
|
if d {
|
||||||
|
g.Value = float64(1.0)
|
||||||
|
} else {
|
||||||
|
g.Value = float64(0.0)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("undeterminable type %+v", d)
|
return fmt.Errorf("undeterminable type %+v", d)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue