-
Notifications
You must be signed in to change notification settings - Fork 10
/
librato.go
37 lines (34 loc) · 938 Bytes
/
librato.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Go client for Librato Metrics
//
// <https://github.com/rcrowley/go-librato>
package librato
type Metrics interface {
Close()
GetCounter(name string) chan int64
GetCustomCounter(name string) chan map[string]int64
GetCustomGauge(name string) chan map[string]int64
GetGauge(name string) chan int64
NewCounter(name string) chan int64
NewCustomCounter(name string) chan map[string]int64
NewCustomGauge(name string) chan map[string]int64
NewGauge(name string) chan int64
Wait()
}
func handle(i interface{}, bodyMetric tmetric) bool {
var obj map[string]int64
var ok bool
switch ch := i.(type) {
case chan int64:
bodyMetric["value"], ok = <-ch
case chan map[string]int64:
obj, ok = <-ch
for k, v := range obj {
bodyMetric[k] = v
}
}
return ok
}
// models http://dev.librato.com/v1/post/metrics (3) Array format (JSON only)
type tbody map[string]tibody
type tibody []tmetric
type tmetric map[string]interface{}