github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/cdc/puller/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 puller
    15  
    16  import (
    17  	"time"
    18  
    19  	"github.com/prometheus/client_golang/prometheus"
    20  )
    21  
    22  const (
    23  	defaultMetricInterval = time.Second * 15
    24  )
    25  
    26  var (
    27  	kvEventCounter = prometheus.NewCounterVec(
    28  		prometheus.CounterOpts{
    29  			Namespace: "ticdc",
    30  			Subsystem: "puller",
    31  			Name:      "kv_event_count",
    32  			Help:      "The number of events received from kv client event channel",
    33  		}, []string{"capture", "changefeed", "type"})
    34  	txnCollectCounter = prometheus.NewCounterVec(
    35  		prometheus.CounterOpts{
    36  			Namespace: "ticdc",
    37  			Subsystem: "puller",
    38  			Name:      "txn_collect_event_count",
    39  			Help:      "The number of events received from txn collector",
    40  		}, []string{"capture", "changefeed", "type"})
    41  	pullerResolvedTsGauge = prometheus.NewGaugeVec(
    42  		prometheus.GaugeOpts{
    43  			Namespace: "ticdc",
    44  			Subsystem: "puller",
    45  			Name:      "resolved_ts",
    46  			Help:      "puller forward resolved ts",
    47  		}, []string{"capture", "changefeed"})
    48  	outputChanSizeHistogram = prometheus.NewHistogramVec(
    49  		prometheus.HistogramOpts{
    50  			Namespace: "ticdc",
    51  			Subsystem: "puller",
    52  			Name:      "output_chan_size",
    53  			Help:      "Puller entry buffer size",
    54  			Buckets:   prometheus.ExponentialBuckets(1, 2, 8),
    55  		}, []string{"capture", "changefeed"})
    56  	memBufferSizeGauge = prometheus.NewGaugeVec(
    57  		prometheus.GaugeOpts{
    58  			Namespace: "ticdc",
    59  			Subsystem: "puller",
    60  			Name:      "mem_buffer_size",
    61  			Help:      "Puller in memory buffer size",
    62  		}, []string{"capture", "changefeed"})
    63  	eventChanSizeHistogram = prometheus.NewHistogramVec(
    64  		prometheus.HistogramOpts{
    65  			Namespace: "ticdc",
    66  			Subsystem: "puller",
    67  			Name:      "event_chan_size",
    68  			Help:      "Puller event channel size",
    69  			Buckets:   prometheus.ExponentialBuckets(1, 2, 8),
    70  		}, []string{"capture", "changefeed"})
    71  	entrySorterResolvedChanSizeGauge = prometheus.NewGaugeVec(
    72  		prometheus.GaugeOpts{
    73  			Namespace: "ticdc",
    74  			Subsystem: "puller",
    75  			Name:      "entry_sorter_resolved_chan_size",
    76  			Help:      "Puller entry sorter resolved channel size",
    77  		}, []string{"capture", "changefeed", "table"})
    78  	entrySorterOutputChanSizeGauge = prometheus.NewGaugeVec(
    79  		prometheus.GaugeOpts{
    80  			Namespace: "ticdc",
    81  			Subsystem: "puller",
    82  			Name:      "entry_sorter_output_chan_size",
    83  			Help:      "Puller entry sorter output channel size",
    84  		}, []string{"capture", "changefeed", "table"})
    85  	entrySorterUnsortedSizeGauge = prometheus.NewGaugeVec(
    86  		prometheus.GaugeOpts{
    87  			Namespace: "ticdc",
    88  			Subsystem: "puller",
    89  			Name:      "entry_sorter_unsorted_size",
    90  			Help:      "Puller entry sorter unsorted items size",
    91  		}, []string{"capture", "changefeed", "table"})
    92  	entrySorterSortDuration = prometheus.NewHistogramVec(
    93  		prometheus.HistogramOpts{
    94  			Namespace: "ticdc",
    95  			Subsystem: "puller",
    96  			Name:      "entry_sorter_sort",
    97  			Help:      "Bucketed histogram of processing time (s) of sort in entry sorter.",
    98  			Buckets:   prometheus.ExponentialBuckets(0.000001, 10, 10),
    99  		}, []string{"capture", "changefeed", "table"})
   100  	entrySorterMergeDuration = prometheus.NewHistogramVec(
   101  		prometheus.HistogramOpts{
   102  			Namespace: "ticdc",
   103  			Subsystem: "puller",
   104  			Name:      "entry_sorter_merge",
   105  			Help:      "Bucketed histogram of processing time (s) of merge in entry sorter.",
   106  			Buckets:   prometheus.ExponentialBuckets(0.000001, 10, 10),
   107  		}, []string{"capture", "changefeed", "table"})
   108  )
   109  
   110  // InitMetrics registers all metrics in this file
   111  func InitMetrics(registry *prometheus.Registry) {
   112  	registry.MustRegister(kvEventCounter)
   113  	registry.MustRegister(txnCollectCounter)
   114  	registry.MustRegister(pullerResolvedTsGauge)
   115  	registry.MustRegister(memBufferSizeGauge)
   116  	registry.MustRegister(outputChanSizeHistogram)
   117  	registry.MustRegister(eventChanSizeHistogram)
   118  	registry.MustRegister(entrySorterResolvedChanSizeGauge)
   119  	registry.MustRegister(entrySorterOutputChanSizeGauge)
   120  	registry.MustRegister(entrySorterUnsortedSizeGauge)
   121  	registry.MustRegister(entrySorterSortDuration)
   122  	registry.MustRegister(entrySorterMergeDuration)
   123  }