forked from QubitProducts/bamboo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
51 lines (41 loc) · 798 Bytes
/
types.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
package g2s
import (
"fmt"
)
type sendable interface {
Message() string
}
type sampling struct {
enabled bool
rate float32
}
func (s *sampling) Suffix() string {
if s.enabled {
return fmt.Sprintf("|@%f", s.rate)
}
return ""
}
type counterUpdate struct {
bucket string
n int
sampling
}
func (u *counterUpdate) Message() string {
return fmt.Sprintf("%s:%d|c%s\n", u.bucket, u.n, u.sampling.Suffix())
}
type timingUpdate struct {
bucket string
ms int
sampling
}
func (u *timingUpdate) Message() string {
return fmt.Sprintf("%s:%d|ms%s\n", u.bucket, u.ms, u.sampling.Suffix())
}
type gaugeUpdate struct {
bucket string
val string
sampling
}
func (u *gaugeUpdate) Message() string {
return fmt.Sprintf("%s:%s|g%s\n", u.bucket, u.val, u.sampling.Suffix())
}