github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/txnwait/metrics.go (about) 1 // Copyright 2019 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 txnwait 12 13 import ( 14 "time" 15 16 "github.com/cockroachdb/cockroach/pkg/util/metric" 17 ) 18 19 // Metrics contains all the txnqueue related metrics. 20 type Metrics struct { 21 PusheeWaiting *metric.Gauge 22 PusherWaiting *metric.Gauge 23 QueryWaiting *metric.Gauge 24 PusherSlow *metric.Gauge 25 PusherWaitTime *metric.Histogram 26 QueryWaitTime *metric.Histogram 27 DeadlocksTotal *metric.Counter 28 } 29 30 // NewMetrics creates a new Metrics instance with all related metric fields. 31 func NewMetrics(histogramWindowInterval time.Duration) *Metrics { 32 return &Metrics{ 33 PusheeWaiting: metric.NewGauge( 34 metric.Metadata{ 35 Name: "txnwaitqueue.pushee.waiting", 36 Help: "Number of pushees on the txn wait queue", 37 Measurement: "Waiting Pushees", 38 Unit: metric.Unit_COUNT, 39 }, 40 ), 41 42 PusherWaiting: metric.NewGauge( 43 metric.Metadata{ 44 Name: "txnwaitqueue.pusher.waiting", 45 Help: "Number of pushers on the txn wait queue", 46 Measurement: "Waiting Pushers", 47 Unit: metric.Unit_COUNT, 48 }, 49 ), 50 51 QueryWaiting: metric.NewGauge( 52 metric.Metadata{ 53 Name: "txnwaitqueue.query.waiting", 54 Help: "Number of transaction status queries waiting for an updated transaction record", 55 Measurement: "Waiting Queries", 56 Unit: metric.Unit_COUNT, 57 }, 58 ), 59 60 PusherSlow: metric.NewGauge( 61 metric.Metadata{ 62 Name: "txnwaitqueue.pusher.slow", 63 Help: "The total number of cases where a pusher waited more than the excessive wait threshold", 64 Measurement: "Slow Pushers", 65 Unit: metric.Unit_COUNT, 66 }, 67 ), 68 69 PusherWaitTime: metric.NewHistogram( 70 metric.Metadata{ 71 Name: "txnwaitqueue.pusher.wait_time", 72 Help: "Histogram of durations spent in queue by pushers", 73 Measurement: "Pusher wait time", 74 Unit: metric.Unit_NANOSECONDS, 75 }, 76 histogramWindowInterval, 77 time.Hour.Nanoseconds(), 78 1, 79 ), 80 81 QueryWaitTime: metric.NewHistogram( 82 metric.Metadata{ 83 Name: "txnwaitqueue.query.wait_time", 84 Help: "Histogram of durations spent in queue by queries", 85 Measurement: "Query wait time", 86 Unit: metric.Unit_NANOSECONDS, 87 }, 88 histogramWindowInterval, 89 time.Hour.Nanoseconds(), 90 1, 91 ), 92 93 DeadlocksTotal: metric.NewCounter( 94 metric.Metadata{ 95 Name: "txnwaitqueue.deadlocks_total", 96 Help: "Number of deadlocks detected by the txn wait queue", 97 Measurement: "Deadlocks", 98 Unit: metric.Unit_COUNT, 99 }, 100 ), 101 } 102 }