forked from newrelic/nri-flex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.go
44 lines (38 loc) · 1.04 KB
/
common.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
package load
import (
"sync"
"time"
)
// TimestampMs create a timestamp in milliseconds
func TimestampMs() int64 {
return time.Now().UnixNano() / int64(time.Millisecond)
}
// FlexStatusCounter count internal metrics
var FlexStatusCounter = struct {
sync.RWMutex
M map[string]int
}{M: make(map[string]int)}
// StatusCounterIncrement increment the status counter for a particular key
func StatusCounterIncrement(key string) {
FlexStatusCounter.Lock()
FlexStatusCounter.M[key]++
FlexStatusCounter.Unlock()
}
// StatusCounterRead the status counter for a particular key
func StatusCounterRead(key string) int {
FlexStatusCounter.Lock()
value := FlexStatusCounter.M[key]
FlexStatusCounter.Unlock()
return value
}
// Refresh Helper function used for testing
func Refresh() {
FlexStatusCounter.M = make(map[string]int)
FlexStatusCounter.M["EventCount"] = 0
FlexStatusCounter.M["EventDropCount"] = 0
FlexStatusCounter.M["ConfigsProcessed"] = 0
Args.ConfigDir = ""
Args.ConfigFile = ""
Args.ContainerDiscovery = false
Args.ContainerDiscoveryDir = ""
}