// statToValue converts from a stats.Stat type to a JSON representable value. // This is preferred to just calling the String() for things like numbers, so that // InfluxDB can also represent the metrics as numbers. // TODO(aaijazi): this needs to be extended to support better serialization of other types.. // It's probably good to do this after InfluxDB 0.9 is released, as it has has better support // for arbitrary dict values (as tags). func statToValue(v expvar.Var) interface{} { switch v := v.(type) { case *stats.Float: return v.Get() case *stats.Int: return v.Get() case stats.FloatFunc: return v() case stats.IntFunc: return v() default: return v.String() } }