github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/pkg/sink/observer/metrics.go (about)

     1  // Copyright 2023 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 observer
    15  
    16  import "github.com/prometheus/client_golang/prometheus"
    17  
    18  var (
    19  	tidbConnIdleDurationGauge = prometheus.NewGaugeVec(
    20  		prometheus.GaugeOpts{
    21  			Namespace: "ticdc",
    22  			Subsystem: "observer",
    23  			Name:      "tidb_conn_idle_duration",
    24  			Help:      "Diagnose data of idle time of tidb connections",
    25  		}, []string{"instance", "in_txn", "quantile"})
    26  	tidbConnCountGauge = prometheus.NewGaugeVec(
    27  		prometheus.GaugeOpts{
    28  			Namespace: "ticdc",
    29  			Subsystem: "observer",
    30  			Name:      "tidb_connection_count",
    31  			Help:      "Diagnose data of tidb connection count",
    32  		}, []string{"instance"})
    33  	tidbQueryDurationGauge = prometheus.NewGaugeVec(
    34  		prometheus.GaugeOpts{
    35  			Namespace: "ticdc",
    36  			Subsystem: "observer",
    37  			Name:      "tidb_query_duration",
    38  			Help:      "Diagnose data of tidb query duration(p90)",
    39  		}, []string{"instance", "sql_type"})
    40  	tidbTxnDurationGauge = prometheus.NewGaugeVec(
    41  		prometheus.GaugeOpts{
    42  			Namespace: "ticdc",
    43  			Subsystem: "observer",
    44  			Name:      "tidb_txn_duration",
    45  			Help:      "Diagnose data of tidb transaction duration(p95)",
    46  		}, []string{"instance", "type"})
    47  )
    48  
    49  // InitMetrics registers all metrics in this file.
    50  func InitMetrics(registry *prometheus.Registry) {
    51  	registry.MustRegister(tidbConnIdleDurationGauge)
    52  	registry.MustRegister(tidbConnCountGauge)
    53  	registry.MustRegister(tidbQueryDurationGauge)
    54  	registry.MustRegister(tidbTxnDurationGauge)
    55  }