File: interfaces.go

package info (click to toggle)
golang-github-raintank-met 0.0~git20190828.80f9c6e-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 745 bytes parent folder | download | duplicates (3)
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
package met

import "time"

type Backend interface {
	NewCount(key string) Count
	NewGauge(key string, val int64) Gauge
	NewMeter(key string, val int64) Meter
	NewTimer(key string, val time.Duration) Timer
}

// Count is a type that counts how many hits it's seen in each given interval
// and computes the rate per second
// it's not a long-running counter.
// values are explicit
type Count interface {
	Inc(val int64)
}

// gauge makes sure its value is explicit (i.e. for statsd, keep sending)
type Gauge interface {
	Dec(val int64)
	Inc(val int64)
	Value(val int64)
}

// like a timer, but not just for timings
type Meter interface {
	Value(val int64)
}

// computes stasticical summaries
type Timer interface {
	Value(val time.Duration)
}