github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/raftentry/metrics.go (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package raftentry 12 13 import "github.com/cockroachdb/cockroach/pkg/util/metric" 14 15 var ( 16 metaEntryCacheSize = metric.Metadata{ 17 Name: "raft.entrycache.size", 18 Help: "Number of Raft entries in the Raft entry cache", 19 Measurement: "Entry Count", 20 Unit: metric.Unit_COUNT, 21 } 22 metaEntryCacheBytes = metric.Metadata{ 23 Name: "raft.entrycache.bytes", 24 Help: "Aggregate size of all Raft entries in the Raft entry cache", 25 Measurement: "Entry Bytes", 26 Unit: metric.Unit_BYTES, 27 } 28 metaEntryCacheAccesses = metric.Metadata{ 29 Name: "raft.entrycache.accesses", 30 Help: "Number of cache lookups in the Raft entry cache", 31 Measurement: "Accesses", 32 Unit: metric.Unit_COUNT, 33 } 34 metaEntryCacheHits = metric.Metadata{ 35 Name: "raft.entrycache.hits", 36 Help: "Number of successful cache lookups in the Raft entry cache", 37 Measurement: "Hits", 38 Unit: metric.Unit_COUNT, 39 } 40 ) 41 42 // Metrics is the set of metrics for the raft entry cache. 43 type Metrics struct { 44 // NB: the values in the gauges are updated asynchronously and may hold stale 45 // values in the face of concurrent updates. 46 Size *metric.Gauge 47 Bytes *metric.Gauge 48 Accesses *metric.Counter 49 Hits *metric.Counter 50 } 51 52 func makeMetrics() Metrics { 53 return Metrics{ 54 Size: metric.NewGauge(metaEntryCacheSize), 55 Bytes: metric.NewGauge(metaEntryCacheBytes), 56 Accesses: metric.NewCounter(metaEntryCacheAccesses), 57 Hits: metric.NewCounter(metaEntryCacheHits), 58 } 59 }