aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/metrics/counters.go
blob: 2fc9539d711e8e53eaa319802df45780f0d95a85 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package metrics

import "sync"

//global counter variables
var IndeterminantDecisionsCount int64
var PermitDecisionsCount int64
var DenyDecisionsCount int64
var TotalErrorCount int64
var mu sync.Mutex

// Increment counter
func IncrementIndeterminantDecisionsCount() {
	mu.Lock()
	IndeterminantDecisionsCount++
	mu.Unlock()
}

// returns pointer to the counter
func IndeterminantDecisionsCountRef() *int64 {
	mu.Lock()
	defer mu.Unlock()
	return &IndeterminantDecisionsCount
}

// Increment counter
func IncrementPermitDecisionsCount() {
	mu.Lock()
	PermitDecisionsCount++
	mu.Unlock()
}

// returns pointer to the counter
func PermitDecisionsCountRef() *int64 {
	mu.Lock()
	defer mu.Unlock()
	return &PermitDecisionsCount
}

// Increment counter
func IncrementDenyDecisionsCount() {
	mu.Lock()
	DenyDecisionsCount++
	mu.Unlock()
}

// returns pointer to the counter
func DenyDecisionsCountRef() *int64 {
	mu.Lock()
	defer mu.Unlock()
	return &DenyDecisionsCount
}

// Increment counter
func IncrementTotalErrorCount() {
	mu.Lock()
	TotalErrorCount++
	mu.Unlock()
}

// returns pointer to the counter
func TotalErrorCountRef() *int64 {
	mu.Lock()
	defer mu.Unlock()
	return &TotalErrorCount
}