github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/compactor/metrics.go (about) 1 // Copyright 2017 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 compactor 12 13 import "github.com/cockroachdb/cockroach/pkg/util/metric" 14 15 // Metrics holds all metrics relating to a Compactor. 16 type Metrics struct { 17 BytesQueued *metric.Gauge 18 BytesSkipped *metric.Counter 19 BytesCompacted *metric.Counter 20 CompactionSuccesses *metric.Counter 21 CompactionFailures *metric.Counter 22 CompactingNanos *metric.Counter 23 } 24 25 // MetricStruct implements the metrics.Struct interface. 26 func (Metrics) MetricStruct() {} 27 28 var _ metric.Struct = Metrics{} 29 30 var ( 31 metaBytesQueued = metric.Metadata{ 32 Name: "compactor.suggestionbytes.queued", 33 Help: "Number of logical bytes in suggested compactions in the queue", 34 Measurement: "Logical Bytes", 35 Unit: metric.Unit_BYTES, 36 } 37 metaBytesSkipped = metric.Metadata{ 38 Name: "compactor.suggestionbytes.skipped", 39 Help: "Number of logical bytes in suggested compactions which were not compacted", 40 Measurement: "Logical Bytes", 41 Unit: metric.Unit_BYTES, 42 } 43 metaBytesCompacted = metric.Metadata{ 44 Name: "compactor.suggestionbytes.compacted", 45 Help: "Number of logical bytes compacted from suggested compactions", 46 Measurement: "Logical Bytes", 47 Unit: metric.Unit_BYTES, 48 } 49 metaCompactionSuccesses = metric.Metadata{ 50 Name: "compactor.compactions.success", 51 Help: "Number of successful compaction requests sent to the storage engine", 52 Measurement: "Compaction Requests", 53 Unit: metric.Unit_COUNT, 54 } 55 metaCompactionFailures = metric.Metadata{ 56 Name: "compactor.compactions.failure", 57 Help: "Number of failed compaction requests sent to the storage engine", 58 Measurement: "Compaction Requests", 59 Unit: metric.Unit_COUNT, 60 } 61 metaCompactingNanos = metric.Metadata{ 62 Name: "compactor.compactingnanos", 63 Help: "Number of nanoseconds spent compacting ranges", 64 Measurement: "Processing Time", 65 Unit: metric.Unit_NANOSECONDS, 66 } 67 ) 68 69 // makeMetrics returns a Metrics struct. 70 func makeMetrics() Metrics { 71 return Metrics{ 72 BytesQueued: metric.NewGauge(metaBytesQueued), 73 BytesSkipped: metric.NewCounter(metaBytesSkipped), 74 BytesCompacted: metric.NewCounter(metaBytesCompacted), 75 CompactionSuccesses: metric.NewCounter(metaCompactionSuccesses), 76 CompactionFailures: metric.NewCounter(metaCompactionFailures), 77 CompactingNanos: metric.NewCounter(metaCompactingNanos), 78 } 79 }