github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/txnrecovery/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 txnrecovery
    12  
    13  import "github.com/cockroachdb/cockroach/pkg/util/metric"
    14  
    15  // Metrics holds all metrics relating to a transaction recovery Manager.
    16  type Metrics struct {
    17  	AttemptsPending      *metric.Gauge
    18  	Attempts             *metric.Counter
    19  	SuccessesAsCommitted *metric.Counter
    20  	SuccessesAsAborted   *metric.Counter
    21  	SuccessesAsPending   *metric.Counter
    22  	Failures             *metric.Counter
    23  }
    24  
    25  // makeMetrics creates a new Metrics instance with all related metric fields.
    26  func makeMetrics() Metrics {
    27  	return Metrics{
    28  		AttemptsPending: metric.NewGauge(
    29  			metric.Metadata{
    30  				Name:        "txnrecovery.attempts.pending",
    31  				Help:        "Number of transaction recovery attempts currently in-flight",
    32  				Measurement: "Recovery Attempts",
    33  				Unit:        metric.Unit_COUNT,
    34  			},
    35  		),
    36  
    37  		Attempts: metric.NewCounter(
    38  			metric.Metadata{
    39  				Name:        "txnrecovery.attempts.total",
    40  				Help:        "Number of transaction recovery attempts executed",
    41  				Measurement: "Recovery Attempts",
    42  				Unit:        metric.Unit_COUNT,
    43  			},
    44  		),
    45  
    46  		SuccessesAsCommitted: metric.NewCounter(
    47  			metric.Metadata{
    48  				Name:        "txnrecovery.successes.committed",
    49  				Help:        "Number of transaction recovery attempts that committed a transaction",
    50  				Measurement: "Recovery Attempts",
    51  				Unit:        metric.Unit_COUNT,
    52  			},
    53  		),
    54  
    55  		SuccessesAsAborted: metric.NewCounter(
    56  			metric.Metadata{
    57  				Name:        "txnrecovery.successes.aborted",
    58  				Help:        "Number of transaction recovery attempts that aborted a transaction",
    59  				Measurement: "Recovery Attempts",
    60  				Unit:        metric.Unit_COUNT,
    61  			},
    62  		),
    63  
    64  		SuccessesAsPending: metric.NewCounter(
    65  			metric.Metadata{
    66  				Name:        "txnrecovery.successes.pending",
    67  				Help:        "Number of transaction recovery attempts that left a transaction pending",
    68  				Measurement: "Recovery Attempts",
    69  				Unit:        metric.Unit_COUNT,
    70  			},
    71  		),
    72  
    73  		Failures: metric.NewCounter(
    74  			metric.Metadata{
    75  				Name:        "txnrecovery.failures",
    76  				Help:        "Number of transaction recovery attempts that failed",
    77  				Measurement: "Recovery Attempts",
    78  				Unit:        metric.Unit_COUNT,
    79  			},
    80  		),
    81  	}
    82  }