-
Notifications
You must be signed in to change notification settings - Fork 175
/
state_synchronization.go
115 lines (96 loc) · 4.04 KB
/
state_synchronization.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package metrics
import (
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/onflow/flow-go/module"
)
type ExecutionDataServiceCollector struct {
executionDataAddDuration prometheus.Histogram
executionDataGetDuration prometheus.Histogram
executionDataAddInProgress prometheus.Gauge
executionDataGetInProgress prometheus.Gauge
executionDataAddFailCount prometheus.Counter
executionDataGetFailCount prometheus.Counter
executionDataBlobTreeSize prometheus.Histogram
}
func NewExecutionDataServiceCollector() module.ExecutionDataServiceMetrics {
executionDataAddDuration := promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_add_duration_ms",
Help: "the duration of execution data add operation",
Buckets: []float64{1, 100, 500, 1000, 2000, 5000},
})
executionDataAddInProgress := promauto.NewGauge(prometheus.GaugeOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_add_in_progress",
Help: "number of concurrently running execution data add operations",
})
executionDataAddFailCount := promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_add_fail_total",
Help: "number of failed execution data add operations",
})
executionDataGetDuration := promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_get_duration_ms",
Help: "the duration of execution data get operation",
Buckets: []float64{1, 100, 500, 1000, 2000, 5000},
})
executionDataGetInProgress := promauto.NewGauge(prometheus.GaugeOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_get_in_progress",
Help: "number of concurrently running execution data get operations",
})
executionDataGetFailCount := promauto.NewCounter(prometheus.CounterOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_get_fail_total",
Help: "number of failed execution data get operations",
})
executionDataBlobTreeSize := promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: namespaceStateSync,
Subsystem: subsystemExecutionDataService,
Name: "execution_data_blob_tree_size",
Help: "the size execution data blob tree",
Buckets: []float64{1, 1000, 10000, 50000, 100000, 500000, 1000000, 10000000, 50000000, 100000000, 250000000, 500000000},
})
return &ExecutionDataServiceCollector{
executionDataAddDuration: executionDataAddDuration,
executionDataAddInProgress: executionDataAddInProgress,
executionDataAddFailCount: executionDataAddFailCount,
executionDataGetDuration: executionDataGetDuration,
executionDataGetInProgress: executionDataGetInProgress,
executionDataGetFailCount: executionDataGetFailCount,
executionDataBlobTreeSize: executionDataBlobTreeSize,
}
}
func (ec *ExecutionDataServiceCollector) ExecutionDataAddStarted() {
ec.executionDataAddInProgress.Inc()
}
func (ec *ExecutionDataServiceCollector) ExecutionDataAddFinished(duration time.Duration, success bool, blobTreeSize uint64) {
ec.executionDataAddInProgress.Dec()
ec.executionDataAddDuration.Observe(float64(duration.Milliseconds()))
if !success {
ec.executionDataAddFailCount.Inc()
} else {
ec.executionDataBlobTreeSize.Observe(float64(blobTreeSize))
}
}
func (ec *ExecutionDataServiceCollector) ExecutionDataGetStarted() {
ec.executionDataGetInProgress.Inc()
}
func (ec *ExecutionDataServiceCollector) ExecutionDataGetFinished(duration time.Duration, success bool, blobTreeSize uint64) {
ec.executionDataGetInProgress.Dec()
ec.executionDataGetDuration.Observe(float64(duration.Milliseconds()))
if !success {
ec.executionDataGetFailCount.Inc()
} else {
ec.executionDataBlobTreeSize.Observe(float64(blobTreeSize))
}
}