forked from rubrikinc/kronos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
39 lines (35 loc) · 1.42 KB
/
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
package kronosstats
import (
"time"
"github.com/cockroachdb/cockroach/pkg/util/metric"
)
// KronosMetrics is used to record metrics of Kronos
type KronosMetrics struct {
// Delta is the offset between local time with kronos time.
Delta *metric.Gauge
// IsOracle is 1 if the current server is the oracle, otherwise 0.
IsOracle *metric.Gauge
// OverthrowAttemptCount is the number of oracle overthrow attempts.
OverthrowAttemptCount *metric.Counter
// RTT is the histogram of RTT of oracle time queries.
RTT *metric.Histogram
// SyncSuccessCount is the number of successful time syncs with the oracle.
SyncSuccessCount *metric.Counter
// SyncFailureCount is the number of failed time syncs with the oracle.
SyncFailureCount *metric.Counter
// TimeCap is an upper bound to kronos time.
TimeCap *metric.Gauge
}
// NewMetrics returns KronosMetrics which can be used to record metrics
func NewMetrics() *KronosMetrics {
return &KronosMetrics{
// Percentile values of RTT is over last 1 minute
Delta: metric.NewGauge(MetaKronosDelta),
IsOracle: metric.NewGauge(MetaKronosIsOracle),
OverthrowAttemptCount: metric.NewCounter(MetaKronosOverthrowCounter),
RTT: metric.NewLatency(MetaKronosRTT, time.Minute),
SyncFailureCount: metric.NewCounter(MetaKronosSyncFailure),
SyncSuccessCount: metric.NewCounter(MetaKronosSyncSuccess),
TimeCap: metric.NewGauge(MetaKronosTimeCap),
}
}