github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/protectedts/ptreconcile/metrics.go (about) 1 // Copyright 2020 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 ptreconcile 12 13 import ( 14 "github.com/cockroachdb/cockroach/pkg/util/metric" 15 io_prometheus_client "github.com/prometheus/client_model/go" 16 ) 17 18 // Metrics encapsulates the metrics exported by the Reconciler. 19 type Metrics struct { 20 ReconcilationRuns *metric.Counter 21 RecordsProcessed *metric.Counter 22 RecordsRemoved *metric.Counter 23 ReconciliationErrors *metric.Counter 24 } 25 26 func makeMetrics() Metrics { 27 return Metrics{ 28 ReconcilationRuns: metric.NewCounter(metaReconciliationRuns), 29 RecordsProcessed: metric.NewCounter(metaRecordsProcessed), 30 RecordsRemoved: metric.NewCounter(metaRecordsRemoved), 31 ReconciliationErrors: metric.NewCounter(metaReconciliationErrors), 32 } 33 } 34 35 var _ metric.Struct = (*Metrics)(nil) 36 37 // MetricStruct makes Metrics a metric.Struct. 38 func (m *Metrics) MetricStruct() {} 39 40 var ( 41 metaReconciliationRuns = metric.Metadata{ 42 Name: "kv.protectedts.reconciliation.num_runs", 43 Help: "number of successful reconciliation runs on this node", 44 Measurement: "Count", 45 Unit: metric.Unit_COUNT, 46 MetricType: io_prometheus_client.MetricType_COUNTER, 47 } 48 metaRecordsProcessed = metric.Metadata{ 49 Name: "kv.protectedts.reconciliation.records_processed", 50 Help: "number of records processed without error during reconciliation on this node", 51 Measurement: "Count", 52 Unit: metric.Unit_COUNT, 53 MetricType: io_prometheus_client.MetricType_COUNTER, 54 } 55 metaRecordsRemoved = metric.Metadata{ 56 Name: "kv.protectedts.reconciliation.records_removed", 57 Help: "number of records removed during reconciliation runs on this node", 58 Measurement: "Count", 59 Unit: metric.Unit_COUNT, 60 MetricType: io_prometheus_client.MetricType_COUNTER, 61 } 62 metaReconciliationErrors = metric.Metadata{ 63 Name: "kv.protectedts.reconciliation.errors", 64 Help: "number of errors encountered during reconciliation runs on this node", 65 Measurement: "Count", 66 Unit: metric.Unit_COUNT, 67 MetricType: io_prometheus_client.MetricType_COUNTER, 68 } 69 )