-
Notifications
You must be signed in to change notification settings - Fork 5
/
info_metrics.go
46 lines (38 loc) · 1.12 KB
/
info_metrics.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
package source
import (
"github.com/Cistern/cistern/message"
metricsPackage "github.com/Cistern/cistern/state/metrics"
)
const InfoMetricsClassName = "metrics"
type InfoMetricsClass struct {
registry *metricsPackage.MetricRegistry
sourceAddress string
outbound chan *message.Message
}
func NewInfoMetricsClass(registry *metricsPackage.MetricRegistry,
sourceAddress string, outbound chan *message.Message) *InfoMetricsClass {
c := &InfoMetricsClass{
registry: registry,
sourceAddress: sourceAddress,
outbound: outbound,
}
return c
}
func (c *InfoMetricsClass) Name() string {
return InfoMetricsClassName
}
func (c *InfoMetricsClass) Category() string {
return "info"
}
func (c *InfoMetricsClass) OutboundMessages() chan *message.Message {
return c.outbound
}
func (c *InfoMetricsClass) Process(m *message.Message) {
metricsData := m.Content.(metricsPackage.MessageContent)
c.registry.Lock()
defer c.registry.Unlock()
for name, v := range metricsData {
c.registry.Update(name, v.Type, v.Value)
//log.Printf("%s,source=%s value=%f %d", name, c.sourceAddress, updatedState, m.Timestamp*1e9)
}
}