Tizen_4.0 base
[platform/upstream/docker-engine.git] / vendor / github.com / armon / go-metrics / sink.go
1 package metrics
2
3 // The MetricSink interface is used to transmit metrics information
4 // to an external system
5 type MetricSink interface {
6         // A Gauge should retain the last value it is set to
7         SetGauge(key []string, val float32)
8
9         // Should emit a Key/Value pair for each call
10         EmitKey(key []string, val float32)
11
12         // Counters should accumulate values
13         IncrCounter(key []string, val float32)
14
15         // Samples are for timing information, where quantiles are used
16         AddSample(key []string, val float32)
17 }
18
19 // BlackholeSink is used to just blackhole messages
20 type BlackholeSink struct{}
21
22 func (*BlackholeSink) SetGauge(key []string, val float32)    {}
23 func (*BlackholeSink) EmitKey(key []string, val float32)     {}
24 func (*BlackholeSink) IncrCounter(key []string, val float32) {}
25 func (*BlackholeSink) AddSample(key []string, val float32)   {}
26
27 // FanoutSink is used to sink to fanout values to multiple sinks
28 type FanoutSink []MetricSink
29
30 func (fh FanoutSink) SetGauge(key []string, val float32) {
31         for _, s := range fh {
32                 s.SetGauge(key, val)
33         }
34 }
35
36 func (fh FanoutSink) EmitKey(key []string, val float32) {
37         for _, s := range fh {
38                 s.EmitKey(key, val)
39         }
40 }
41
42 func (fh FanoutSink) IncrCounter(key []string, val float32) {
43         for _, s := range fh {
44                 s.IncrCounter(key, val)
45         }
46 }
47
48 func (fh FanoutSink) AddSample(key []string, val float32) {
49         for _, s := range fh {
50                 s.AddSample(key, val)
51         }
52 }