Fix librato output support for uint and bool (#4151)
(cherry picked from commit e45822e2e2
)
This commit is contained in:
parent
a9b0cc706b
commit
e50f7f4bf8
|
@ -107,7 +107,6 @@ func (l *Librato) Write(metrics []telegraf.Metric) error {
|
|||
for _, gauge := range gauges {
|
||||
tempGauges = append(tempGauges, gauge)
|
||||
log.Printf("D! Got a gauge: %v\n", gauge)
|
||||
|
||||
}
|
||||
} else {
|
||||
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 {
|
||||
switch d := v.(type) {
|
||||
case int:
|
||||
g.Value = float64(int(d))
|
||||
case int32:
|
||||
g.Value = float64(int32(d))
|
||||
case int64:
|
||||
g.Value = float64(int64(d))
|
||||
case float32:
|
||||
case uint64:
|
||||
g.Value = float64(d)
|
||||
case float64:
|
||||
g.Value = float64(d)
|
||||
case bool:
|
||||
if d {
|
||||
g.Value = float64(1.0)
|
||||
} else {
|
||||
g.Value = float64(0.0)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("undeterminable type %+v", d)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue