forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
160 lines (151 loc) · 6.17 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Copyright 2018 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package metrics
import "github.com/prometheus/client_golang/prometheus"
var (
// PanicCounter measures the count of panics.
PanicCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "panic_total",
Help: "Counter of panic.",
}, []string{LblType})
)
// metrics labels.
const (
LabelSession = "session"
LabelDomain = "domain"
LabelDDLOwner = "ddl-owner"
LabelDDL = "ddl"
LabelDDLSyncer = "ddl-syncer"
LabelGCWorker = "gcworker"
LabelAnalyze = "analyze"
LabelBatchRecvLoop = "batch-recv-loop"
LabelBatchSendLoop = "batch-send-loop"
opSucc = "ok"
opFailed = "err"
LableScope = "scope"
ScopeGlobal = "global"
ScopeSession = "session"
)
// RetLabel returns "ok" when err == nil and "err" when err != nil.
// This could be useful when you need to observe the operation result.
func RetLabel(err error) string {
if err == nil {
return opSucc
}
return opFailed
}
// RegisterMetrics registers the metrics which are ONLY used in TiDB server.
func RegisterMetrics() {
prometheus.MustRegister(AutoAnalyzeCounter)
prometheus.MustRegister(AutoAnalyzeHistogram)
prometheus.MustRegister(AutoIDHistogram)
prometheus.MustRegister(BatchAddIdxHistogram)
prometheus.MustRegister(BindUsageCounter)
prometheus.MustRegister(BindTotalGauge)
prometheus.MustRegister(BindMemoryUsage)
prometheus.MustRegister(CampaignOwnerCounter)
prometheus.MustRegister(ConnGauge)
prometheus.MustRegister(PreparedStmtGauge)
prometheus.MustRegister(CriticalErrorCounter)
prometheus.MustRegister(DDLCounter)
prometheus.MustRegister(AddIndexTotalCounter)
prometheus.MustRegister(DDLWorkerHistogram)
prometheus.MustRegister(DeploySyncerHistogram)
prometheus.MustRegister(DistSQLPartialCountHistogram)
prometheus.MustRegister(DistSQLQueryHistgram)
prometheus.MustRegister(DistSQLScanKeysHistogram)
prometheus.MustRegister(DistSQLScanKeysPartialHistogram)
prometheus.MustRegister(DumpFeedbackCounter)
prometheus.MustRegister(ExecuteErrorCounter)
prometheus.MustRegister(ExecutorCounter)
prometheus.MustRegister(GetTokenDurationHistogram)
prometheus.MustRegister(HandShakeErrorCounter)
prometheus.MustRegister(HandleJobHistogram)
prometheus.MustRegister(SignificantFeedbackCounter)
prometheus.MustRegister(FastAnalyzeHistogram)
prometheus.MustRegister(JobsGauge)
prometheus.MustRegister(KeepAliveCounter)
prometheus.MustRegister(LoadPrivilegeCounter)
prometheus.MustRegister(LoadSchemaCounter)
prometheus.MustRegister(LoadSchemaDuration)
prometheus.MustRegister(MetaHistogram)
prometheus.MustRegister(NewSessionHistogram)
prometheus.MustRegister(OwnerHandleSyncerHistogram)
prometheus.MustRegister(PanicCounter)
prometheus.MustRegister(PlanCacheCounter)
prometheus.MustRegister(PseudoEstimation)
prometheus.MustRegister(QueryDurationHistogram)
prometheus.MustRegister(QueryTotalCounter)
prometheus.MustRegister(SchemaLeaseErrorCounter)
prometheus.MustRegister(ServerEventCounter)
prometheus.MustRegister(SessionExecuteCompileDuration)
prometheus.MustRegister(SessionExecuteParseDuration)
prometheus.MustRegister(SessionExecuteRunDuration)
prometheus.MustRegister(SessionRestrictedSQLCounter)
prometheus.MustRegister(SessionRetry)
prometheus.MustRegister(SessionRetryErrorCounter)
prometheus.MustRegister(StatementPerTransaction)
prometheus.MustRegister(StatsInaccuracyRate)
prometheus.MustRegister(StmtNodeCounter)
prometheus.MustRegister(DbStmtNodeCounter)
prometheus.MustRegister(StoreQueryFeedbackCounter)
prometheus.MustRegister(TiKVBackoffCounter)
prometheus.MustRegister(TiKVBackoffHistogram)
prometheus.MustRegister(TiKVCoprocessorHistogram)
prometheus.MustRegister(TiKVLoadSafepointCounter)
prometheus.MustRegister(TiKVLockResolverCounter)
prometheus.MustRegister(TiKVRawkvCmdHistogram)
prometheus.MustRegister(TiKVRawkvSizeHistogram)
prometheus.MustRegister(TiKVRegionCacheCounter)
prometheus.MustRegister(TiKVRegionErrorCounter)
prometheus.MustRegister(TiKVSecondaryLockCleanupFailureCounter)
prometheus.MustRegister(TiKVSendReqHistogram)
prometheus.MustRegister(TiKVSnapshotCounter)
prometheus.MustRegister(TiKVTxnCmdCounter)
prometheus.MustRegister(TiKVTxnCmdHistogram)
prometheus.MustRegister(TiKVTxnCounter)
prometheus.MustRegister(TiKVTxnRegionsNumHistogram)
prometheus.MustRegister(TiKVTxnWriteKVCountHistogram)
prometheus.MustRegister(TiKVTxnWriteSizeHistogram)
prometheus.MustRegister(TiKVLocalLatchWaitTimeHistogram)
prometheus.MustRegister(TimeJumpBackCounter)
prometheus.MustRegister(TransactionCounter)
prometheus.MustRegister(TransactionDuration)
prometheus.MustRegister(UpdateSelfVersionHistogram)
prometheus.MustRegister(UpdateStatsCounter)
prometheus.MustRegister(WatchOwnerCounter)
prometheus.MustRegister(GCActionRegionResultCounter)
prometheus.MustRegister(GCConfigGauge)
prometheus.MustRegister(GCHistogram)
prometheus.MustRegister(GCJobFailureCounter)
prometheus.MustRegister(GCRegionTooManyLocksCounter)
prometheus.MustRegister(GCWorkerCounter)
prometheus.MustRegister(GCUnsafeDestroyRangeFailuresCounterVec)
prometheus.MustRegister(TSFutureWaitDuration)
prometheus.MustRegister(TotalQueryProcHistogram)
prometheus.MustRegister(TotalCopProcHistogram)
prometheus.MustRegister(TotalCopWaitHistogram)
prometheus.MustRegister(CPUUsagePercentageGauge)
prometheus.MustRegister(TiKVPendingBatchRequests)
prometheus.MustRegister(TiKVBatchWaitDuration)
prometheus.MustRegister(TiKVBatchClientUnavailable)
prometheus.MustRegister(TiKVRangeTaskStats)
prometheus.MustRegister(TiKVRangeTaskPushDuration)
prometheus.MustRegister(HandleSchemaValidate)
prometheus.MustRegister(TiKVTokenWaitDuration)
prometheus.MustRegister(TiKVTxnHeartBeatHistogram)
prometheus.MustRegister(GRPCConnTransientFailureCounter)
}