github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/cdc/sink/metrics.go (about)

     1  // Copyright 2020 PingCAP, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package sink
    15  
    16  import (
    17  	"github.com/prometheus/client_golang/prometheus"
    18  )
    19  
    20  var (
    21  	execBatchHistogram = prometheus.NewHistogramVec(
    22  		prometheus.HistogramOpts{
    23  			Namespace: "ticdc",
    24  			Subsystem: "sink",
    25  			Name:      "txn_batch_size",
    26  			Help:      "Bucketed histogram of batch size of a txn.",
    27  			Buckets:   prometheus.ExponentialBuckets(1, 2, 18),
    28  		}, []string{"capture", "changefeed"})
    29  	execTxnHistogram = prometheus.NewHistogramVec(
    30  		prometheus.HistogramOpts{
    31  			Namespace: "ticdc",
    32  			Subsystem: "sink",
    33  			Name:      "txn_exec_duration",
    34  			Help:      "Bucketed histogram of processing time (s) of a txn.",
    35  			Buckets:   prometheus.ExponentialBuckets(0.002 /* 2 ms */, 2, 18),
    36  		}, []string{"capture", "changefeed"})
    37  	execDDLHistogram = prometheus.NewHistogramVec(
    38  		prometheus.HistogramOpts{
    39  			Namespace: "ticdc",
    40  			Subsystem: "sink",
    41  			Name:      "ddl_exec_duration",
    42  			Help:      "Bucketed histogram of processing time (s) of a ddl.",
    43  			Buckets:   prometheus.ExponentialBuckets(0.01, 2, 18),
    44  		}, []string{"capture", "changefeed"})
    45  	executionErrorCounter = prometheus.NewCounterVec(
    46  		prometheus.CounterOpts{
    47  			Namespace: "ticdc",
    48  			Subsystem: "sink",
    49  			Name:      "execution_error",
    50  			Help:      "total count of execution errors",
    51  		}, []string{"capture", "changefeed"})
    52  	conflictDetectDurationHis = prometheus.NewHistogramVec(
    53  		prometheus.HistogramOpts{
    54  			Namespace: "ticdc",
    55  			Subsystem: "sink",
    56  			Name:      "conflict_detect_duration",
    57  			Help:      "Bucketed histogram of conflict detect time (s) for single DML statement",
    58  			Buckets:   prometheus.ExponentialBuckets(0.001 /* 1 ms */, 2, 20),
    59  		}, []string{"capture", "changefeed"})
    60  	bucketSizeCounter = prometheus.NewCounterVec(
    61  		prometheus.CounterOpts{
    62  			Namespace: "ticdc",
    63  			Subsystem: "sink",
    64  			Name:      "bucket_size",
    65  			Help:      "size of the DML bucket",
    66  		}, []string{"capture", "changefeed", "bucket"})
    67  	totalRowsCountGauge = prometheus.NewGaugeVec(
    68  		prometheus.GaugeOpts{
    69  			Namespace: "ticdc",
    70  			Subsystem: "sink",
    71  			Name:      "total_rows_count",
    72  			Help:      "totla count of rows",
    73  		}, []string{"capture", "changefeed"})
    74  	totalFlushedRowsCountGauge = prometheus.NewGaugeVec(
    75  		prometheus.GaugeOpts{
    76  			Namespace: "ticdc",
    77  			Subsystem: "sink",
    78  			Name:      "total_flushed_rows_count",
    79  			Help:      "totla count of flushed rows",
    80  		}, []string{"capture", "changefeed"})
    81  	flushRowChangedDuration = prometheus.NewHistogramVec(
    82  		prometheus.HistogramOpts{
    83  			Namespace: "ticdc",
    84  			Subsystem: "sink",
    85  			Name:      "flush_event_duration_seconds",
    86  			Help:      "Bucketed histogram of processing time (s) of flushing events in processor",
    87  			Buckets:   prometheus.ExponentialBuckets(0.002 /* 2ms */, 2, 20),
    88  		}, []string{"capture", "changefeed", "type"})
    89  	bufferChanSizeGauge = prometheus.NewGaugeVec(
    90  		prometheus.GaugeOpts{
    91  			Namespace: "ticdc",
    92  			Subsystem: "sink",
    93  			Name:      "buffer_chan_size",
    94  			Help:      "size of row changed event buffer channel in sink manager",
    95  		}, []string{"capture", "changefeed"})
    96  )
    97  
    98  // InitMetrics registers all metrics in this file
    99  func InitMetrics(registry *prometheus.Registry) {
   100  	registry.MustRegister(execBatchHistogram)
   101  	registry.MustRegister(execTxnHistogram)
   102  	registry.MustRegister(execDDLHistogram)
   103  	registry.MustRegister(executionErrorCounter)
   104  	registry.MustRegister(conflictDetectDurationHis)
   105  	registry.MustRegister(bucketSizeCounter)
   106  	registry.MustRegister(totalRowsCountGauge)
   107  	registry.MustRegister(totalFlushedRowsCountGauge)
   108  	registry.MustRegister(flushRowChangedDuration)
   109  	registry.MustRegister(bufferChanSizeGauge)
   110  }