-
Notifications
You must be signed in to change notification settings - Fork 1
/
statsd.go
62 lines (52 loc) · 1.3 KB
/
statsd.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package statsd
import (
"time"
)
var (
global Client
)
// Setup enables and configures the global Statsd client.
func Setup(statsdURL string, packetSize int) (err error) {
global, err = NewWithPacketSize(statsdURL, packetSize)
if err != nil {
return err
}
return nil
}
// Flush flushes the buffer on the global Statsd client.
func Flush() {
if global != nil {
global.Flush()
}
}
// Count sends a count metric using the global Statsd client.
func Count(bucket string, value float64, sampleRate float64) {
if global != nil {
global.Count(bucket, value, sampleRate)
}
}
// Gauge sends a gauge metric using the global Statsd client.
func Gauge(bucket string, value float64) {
if global != nil {
global.Gauge(bucket, value)
}
}
// Timing sends a raw timing metric using the global Statsd client.
func Timing(bucket string, value float64) {
if global != nil {
global.Timing(bucket, value)
}
}
// TimingDuration sends a timing metric as a time.Duration using the global
// Statsd client.
func TimingDuration(bucket string, duration time.Duration) {
if global != nil {
global.TimingDuration(bucket, duration)
}
}
// CountUnique sends a unique count metric using the global Statsd client.
func CountUnique(bucket string, value string) {
if global != nil {
global.CountUnique(bucket, value)
}
}