github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/cdc/server/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 server 15 16 import ( 17 "github.com/pingcap/tiflow/cdc/entry" 18 "github.com/pingcap/tiflow/cdc/kv" 19 "github.com/pingcap/tiflow/cdc/owner" 20 "github.com/pingcap/tiflow/cdc/processor" 21 "github.com/pingcap/tiflow/cdc/processor/sourcemanager/sorter" 22 "github.com/pingcap/tiflow/cdc/puller" 23 "github.com/pingcap/tiflow/cdc/puller/memorysorter" 24 redo "github.com/pingcap/tiflow/cdc/redo/common" 25 "github.com/pingcap/tiflow/cdc/scheduler" 26 "github.com/pingcap/tiflow/cdc/sink/metrics" 27 "github.com/pingcap/tiflow/pkg/etcd" 28 "github.com/pingcap/tiflow/pkg/orchestrator" 29 "github.com/pingcap/tiflow/pkg/p2p" 30 "github.com/pingcap/tiflow/pkg/sink/observer" 31 "github.com/pingcap/tiflow/pkg/txnutil/gc" 32 "github.com/prometheus/client_golang/prometheus" 33 "github.com/prometheus/client_golang/prometheus/collectors" 34 tikvmetrics "github.com/tikv/client-go/v2/metrics" 35 ) 36 37 var registry = prometheus.NewRegistry() 38 39 func init() { 40 registry.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{})) 41 registry.MustRegister(prometheus.NewGoCollector( 42 collectors.WithGoCollections(collectors.GoRuntimeMemStatsCollection | collectors.GoRuntimeMetricsCollection))) 43 44 initServerMetrics(registry) 45 kv.InitMetrics(registry) 46 puller.InitMetrics(registry) 47 metrics.InitMetrics(registry) 48 entry.InitMetrics(registry) 49 processor.InitMetrics(registry) 50 owner.InitMetrics(registry) 51 etcd.InitMetrics(registry) 52 orchestrator.InitMetrics(registry) 53 p2p.InitMetrics(registry) 54 sorter.InitMetrics(registry) 55 memorysorter.InitMetrics(registry) 56 redo.InitMetrics(registry) 57 scheduler.InitMetrics(registry) 58 observer.InitMetrics(registry) 59 gc.InitMetrics(registry) 60 // TiKV client metrics, including metrics about resolved and region cache. 61 originalRegistry := prometheus.DefaultRegisterer 62 prometheus.DefaultRegisterer = registry 63 tikvmetrics.InitMetrics("ticdc", "tikvclient") 64 tikvmetrics.RegisterMetrics() 65 prometheus.DefaultRegisterer = originalRegistry 66 }