File: timer.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 (23 lines) | stat: -rw-r--r-- 564 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
package dogstatsd

import "time"
import "github.com/raintank/met"

// note that due the preseeding in init, you shouldn't rely on the count and count_ps summaries
// rather, consider maintaining a separate counter
// see https://github.com/raintank/grafana/issues/133

type Timer struct {
	key     string
	backend Backend
}

func (b Backend) NewTimer(key string, val time.Duration) met.Timer {
	t := Timer{key, b}
	t.Value(val)
	return t
}

func (t Timer) Value(val time.Duration) {
	t.backend.client.TimeInMilliseconds(t.key, val.Seconds()*1000, []string{}, 1)
}