github.com/matrixorigin/matrixone@v1.2.0/pkg/util/metric/v2/txn.go (about) 1 // Copyright 2023 Matrix Origin 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 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package v2 16 17 import ( 18 "github.com/prometheus/client_golang/prometheus" 19 ) 20 21 var ( 22 txnCounter = prometheus.NewCounterVec( 23 prometheus.CounterOpts{ 24 Namespace: "mo", 25 Subsystem: "txn", 26 Name: "total", 27 Help: "Total number of txn created.", 28 }, []string{"type"}) 29 TxnUserCounter = txnCounter.WithLabelValues("user") 30 TxnInternalCounter = txnCounter.WithLabelValues("internal") 31 TxnLeakCounter = txnCounter.WithLabelValues("leak") 32 TxnLongRunningCounter = txnCounter.WithLabelValues("long running") 33 TxnInCommitCounter = txnCounter.WithLabelValues("stuck in commit") 34 TxnInRollbackCounter = txnCounter.WithLabelValues("stuck in rollback") 35 36 txnStatementCounter = prometheus.NewCounterVec( 37 prometheus.CounterOpts{ 38 Namespace: "mo", 39 Subsystem: "txn", 40 Name: "statement_total", 41 Help: "Total number of txn statement executed.", 42 }, []string{"type"}) 43 TxnStatementTotalCounter = txnStatementCounter.WithLabelValues("total") 44 TxnStatementRetryCounter = txnStatementCounter.WithLabelValues("retry") 45 46 txnCommitCounter = prometheus.NewCounterVec( 47 prometheus.CounterOpts{ 48 Namespace: "mo", 49 Subsystem: "txn", 50 Name: "commit_total", 51 Help: "Total number of txn commit handled.", 52 }, []string{"type"}) 53 TxnCNCommitCounter = txnCommitCounter.WithLabelValues("cn") 54 TxnTNReceiveCommitCounter = txnCommitCounter.WithLabelValues("tn-receive") 55 TxnTNCommitHandledCounter = txnCommitCounter.WithLabelValues("tn-handle") 56 57 TxnRollbackCounter = prometheus.NewCounter( 58 prometheus.CounterOpts{ 59 Namespace: "mo", 60 Subsystem: "txn", 61 Name: "rollback_total", 62 Help: "Total number of txn rollback handled.", 63 }) 64 65 txnLockCounter = prometheus.NewCounterVec( 66 prometheus.CounterOpts{ 67 Namespace: "mo", 68 Subsystem: "txn", 69 Name: "lock_total", 70 Help: "Total number of lock op counter.", 71 }, []string{"type"}) 72 TxnLockTotalCounter = txnLockCounter.WithLabelValues("total") 73 TxnLocalLockTotalCounter = txnLockCounter.WithLabelValues("local") 74 TxnRemoteLockTotalCounter = txnLockCounter.WithLabelValues("remote") 75 76 TxnRangesLoadedObjectMetaTotalCounter = prometheus.NewCounter( 77 prometheus.CounterOpts{ 78 Namespace: "mo", 79 Subsystem: "txn", 80 Name: "ranges_loaded_object_meta_total", 81 Help: "Total number of ranges loaded object meta.", 82 }) 83 ) 84 85 var ( 86 txnQueueSizeGauge = prometheus.NewGaugeVec( 87 prometheus.GaugeOpts{ 88 Namespace: "mo", 89 Subsystem: "txn", 90 Name: "queue_size", 91 Help: "Size of txn queues.", 92 }, []string{"type"}) 93 TxnCommitQueueSizeGauge = txnQueueSizeGauge.WithLabelValues("commit") 94 TxnWaitActiveQueueSizeGauge = txnQueueSizeGauge.WithLabelValues("wait-active") 95 TxnActiveQueueSizeGauge = txnQueueSizeGauge.WithLabelValues("active") 96 TxnLockRPCQueueSizeGauge = txnQueueSizeGauge.WithLabelValues("lock-rpc") 97 98 txnCNCommittedLocationQuantityGauge = prometheus.NewGaugeVec( 99 prometheus.GaugeOpts{ 100 Namespace: "mo", 101 Subsystem: "txn", 102 Name: "cn_committed_location_quantity_size", 103 Help: "Quantity of object location the cn have committed to tn.", 104 }, []string{"type"}) 105 106 TxnCNCommittedMetaLocationQuantityGauge = txnCNCommittedLocationQuantityGauge.WithLabelValues("meta_location") 107 TxnCNCommittedDeltaLocationQuantityGauge = txnCNCommittedLocationQuantityGauge.WithLabelValues("delta_location") 108 ) 109 110 var ( 111 txnCommitDurationHistogram = prometheus.NewHistogramVec( 112 prometheus.HistogramOpts{ 113 Namespace: "mo", 114 Subsystem: "txn", 115 Name: "commit_duration_seconds", 116 Help: "Bucketed histogram of txn commit duration.", 117 Buckets: getDurationBuckets(), 118 }, []string{"type"}) 119 TxnCNCommitDurationHistogram = txnCommitDurationHistogram.WithLabelValues("cn") 120 TxnCNSendCommitDurationHistogram = txnCommitDurationHistogram.WithLabelValues("cn-send") 121 TxnCNCommitResponseDurationHistogram = txnCommitDurationHistogram.WithLabelValues("cn-resp") 122 TxnCNCommitWaitLogtailDurationHistogram = txnCommitDurationHistogram.WithLabelValues("cn-wait-logtail") 123 TxnTNCommitDurationHistogram = txnCommitDurationHistogram.WithLabelValues("tn") 124 125 TxnLifeCycleDurationHistogram = prometheus.NewHistogram( 126 prometheus.HistogramOpts{ 127 Namespace: "mo", 128 Subsystem: "txn", 129 Name: "life_duration_seconds", 130 Help: "Bucketed histogram of txn life cycle duration.", 131 Buckets: getDurationBuckets(), 132 }) 133 134 TxnLifeCycleStatementsTotalHistogram = prometheus.NewHistogram( 135 prometheus.HistogramOpts{ 136 Namespace: "mo", 137 Subsystem: "txn", 138 Name: "life_statements_total", 139 Help: "Bucketed histogram of statement total in a txn.", 140 Buckets: prometheus.ExponentialBuckets(1, 2.0, 10), 141 }) 142 143 TxnUnlockTableTotalHistogram = prometheus.NewHistogram( 144 prometheus.HistogramOpts{ 145 Namespace: "mo", 146 Subsystem: "txn", 147 Name: "unlock_table_total", 148 Help: "Size of txn unlock tables count.", 149 Buckets: prometheus.ExponentialBuckets(1, 2.0, 4), 150 }) 151 152 txnCreateDurationHistogram = prometheus.NewHistogramVec( 153 prometheus.HistogramOpts{ 154 Namespace: "mo", 155 Subsystem: "txn", 156 Name: "create_duration_seconds", 157 Help: "Bucketed histogram of txn create txn duration.", 158 Buckets: getDurationBuckets(), 159 }, []string{"type"}) 160 TxnCreateTotalDurationHistogram = txnCreateDurationHistogram.WithLabelValues("total") 161 TxnDetermineSnapshotDurationHistogram = txnCreateDurationHistogram.WithLabelValues("determine-snapshot") 162 TxnWaitActiveDurationHistogram = txnCreateDurationHistogram.WithLabelValues("wait-active") 163 164 txnStatementDurationHistogram = prometheus.NewHistogramVec( 165 prometheus.HistogramOpts{ 166 Namespace: "mo", 167 Subsystem: "txn", 168 Name: "statement_duration_seconds", 169 Help: "Bucketed histogram of txn statement duration.", 170 Buckets: getDurationBuckets(), 171 }, []string{"type"}) 172 TxnStatementBuildPlanDurationHistogram = txnStatementDurationHistogram.WithLabelValues("build-plan") 173 TxnStatementExecuteDurationHistogram = txnStatementDurationHistogram.WithLabelValues("execute") 174 TxnStatementExecuteLatencyDurationHistogram = txnStatementDurationHistogram.WithLabelValues("execute-latency") 175 TxnStatementCompileDurationHistogram = txnStatementDurationHistogram.WithLabelValues("compile") 176 TxnStatementScanDurationHistogram = txnStatementDurationHistogram.WithLabelValues("scan") 177 TxnStatementExternalScanDurationHistogram = txnStatementDurationHistogram.WithLabelValues("external-scan") 178 TxnStatementInsertS3DurationHistogram = txnStatementDurationHistogram.WithLabelValues("insert-s3") 179 TxnStatementStatsDurationHistogram = txnStatementDurationHistogram.WithLabelValues("stats") 180 TxnStatementResolveDurationHistogram = txnStatementDurationHistogram.WithLabelValues("resolve") 181 TxnStatementResolveUdfDurationHistogram = txnStatementDurationHistogram.WithLabelValues("resolve-udf") 182 TxnStatementUpdateStatsDurationHistogram = txnStatementDurationHistogram.WithLabelValues("update-stats") 183 TxnStatementUpdateInfoFromZonemapHistogram = txnStatementDurationHistogram.WithLabelValues("update-info-from-zonemap") 184 TxnStatementUpdateStatsInfoMapHistogram = txnStatementDurationHistogram.WithLabelValues("update-stats-info-map") 185 TxnStatementNodesHistogram = txnStatementDurationHistogram.WithLabelValues("nodes") 186 TxnStatementCompileScopeHistogram = txnStatementDurationHistogram.WithLabelValues("compileScope") 187 TxnStatementCompileQueryHistogram = txnStatementDurationHistogram.WithLabelValues("compileQuery") 188 TxnStatementCompilePlanScopeHistogram = txnStatementDurationHistogram.WithLabelValues("compilePlanScope") 189 TxnStatementBuildPlanHistogram = txnStatementDurationHistogram.WithLabelValues("BuildPlan") 190 TxnStatementBuildSelectHistogram = txnStatementDurationHistogram.WithLabelValues("BuildSelect") 191 TxnStatementBuildInsertHistogram = txnStatementDurationHistogram.WithLabelValues("BuildInsert") 192 TxnStatementBuildExplainHistogram = txnStatementDurationHistogram.WithLabelValues("BuildExplain") 193 TxnStatementBuildReplaceHistogram = txnStatementDurationHistogram.WithLabelValues("BuildReplace") 194 TxnStatementBuildUpdateHistogram = txnStatementDurationHistogram.WithLabelValues("BuildUpdate") 195 TxnStatementBuildDeleteHistogram = txnStatementDurationHistogram.WithLabelValues("BuildDelete") 196 TxnStatementBuildLoadHistogram = txnStatementDurationHistogram.WithLabelValues("BuildLoad") 197 198 txnLockDurationHistogram = prometheus.NewHistogramVec( 199 prometheus.HistogramOpts{ 200 Namespace: "mo", 201 Subsystem: "txn", 202 Name: "lock_duration_seconds", 203 Help: "Bucketed histogram of acquire lock duration.", 204 Buckets: getDurationBuckets(), 205 }, []string{"type"}) 206 TxnAcquireLockDurationHistogram = txnLockDurationHistogram.WithLabelValues("acquire") 207 TxnAcquireLockWaitDurationHistogram = txnLockDurationHistogram.WithLabelValues("acquire-wait") 208 TxnHoldLockDurationHistogram = txnLockDurationHistogram.WithLabelValues("hold") 209 210 txnUnlockDurationHistogram = prometheus.NewHistogramVec( 211 prometheus.HistogramOpts{ 212 Namespace: "mo", 213 Subsystem: "txn", 214 Name: "unlock_duration_seconds", 215 Help: "Bucketed histogram of release lock duration.", 216 Buckets: getDurationBuckets(), 217 }, []string{"type"}) 218 TxnUnlockDurationHistogram = txnUnlockDurationHistogram.WithLabelValues("total") 219 TxnUnlockBtreeGetLockDurationHistogram = txnUnlockDurationHistogram.WithLabelValues("btree-get-lock") 220 TxnUnlockBtreeTotalDurationHistogram = txnUnlockDurationHistogram.WithLabelValues("btree-total") 221 TxnLockWorkerHandleDurationHistogram = txnUnlockDurationHistogram.WithLabelValues("worker-handle") 222 223 TxnLockWaitersTotalHistogram = prometheus.NewHistogram( 224 prometheus.HistogramOpts{ 225 Namespace: "mo", 226 Subsystem: "txn", 227 Name: "lock_waiters_total", 228 Help: "Bucketed histogram of waiters count in one lock.", 229 Buckets: prometheus.ExponentialBuckets(1, 2.0, 10), 230 }) 231 232 TxnTableRangeDurationHistogram = prometheus.NewHistogram( 233 prometheus.HistogramOpts{ 234 Namespace: "mo", 235 Subsystem: "txn", 236 Name: "ranges_duration_seconds", 237 Help: "Bucketed histogram of txn table ranges duration.", 238 Buckets: getDurationBuckets(), 239 }) 240 241 TxnCheckPKDupDurationHistogram = prometheus.NewHistogram( 242 prometheus.HistogramOpts{ 243 Namespace: "mo", 244 Subsystem: "txn", 245 Name: "check_pk_dup_duration_seconds", 246 Help: "Bucketed histogram of txn check pk dup duration.", 247 Buckets: getDurationBuckets(), 248 }) 249 250 txnTableRangeSizeHistogram = prometheus.NewHistogramVec( 251 prometheus.HistogramOpts{ 252 Namespace: "mo", 253 Subsystem: "txn", 254 Name: "ranges_duration_size", 255 Help: "Bucketed histogram of txn table ranges size.", 256 Buckets: prometheus.ExponentialBuckets(1, 2.0, 20), 257 }, []string{"type"}) 258 259 TxnRangeSizeHistogram = txnTableRangeSizeHistogram.WithLabelValues("ranges_len") 260 TxnFastRangeSizeHistogram = txnTableRangeSizeHistogram.WithLabelValues("fast_ranges_len") 261 262 txnTNSideDurationHistogram = prometheus.NewHistogramVec( 263 prometheus.HistogramOpts{ 264 Namespace: "mo", 265 Subsystem: "txn", 266 Name: "tn_side_duration_seconds", 267 Help: "Bucketed histogram of txn duration on tn side.", 268 Buckets: getDurationBuckets(), 269 }, []string{"step"}) 270 271 TxnPreparingWaitDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("1-PreparingWait") 272 TxnPreparingDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("2-Preparing") 273 TxnPrepareWalWaitDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("3-PrepareWalWait") 274 TxnPrepareWalDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("4-PrepareWal") 275 TxnPreparedWaitDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("5-PreparedWait") 276 TxnPreparedDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("6-Prepared") 277 278 TxnDequeuePreparedDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("dequeue_prepared") 279 TxnBeforeCommitDurationHistogram = txnTNSideDurationHistogram.WithLabelValues("before_txn_commit") 280 281 txnMpoolDurationHistogram = prometheus.NewHistogramVec( 282 prometheus.HistogramOpts{ 283 Namespace: "mo", 284 Subsystem: "txn", 285 Name: "mpool_duration_seconds", 286 Help: "Bucketed histogram of txn mpool duration.", 287 Buckets: getDurationBuckets(), 288 }, []string{"type"}) 289 TxnMpoolNewDurationHistogram = txnMpoolDurationHistogram.WithLabelValues("new") 290 TxnMpoolDeleteDurationHistogram = txnMpoolDurationHistogram.WithLabelValues("delete") 291 292 txnReaderDurationHistogram = prometheus.NewHistogramVec( 293 prometheus.HistogramOpts{ 294 Namespace: "mo", 295 Subsystem: "txn", 296 Name: "reader_duration_seconds", 297 Help: "Bucketed histogram of reader read duration.", 298 Buckets: getDurationBuckets(), 299 }, []string{"type"}) 300 TxnBlockReaderDurationHistogram = txnReaderDurationHistogram.WithLabelValues("block-reader") 301 TxnMergeReaderDurationHistogram = txnReaderDurationHistogram.WithLabelValues("merge-reader") 302 TxnBlockMergeReaderDurationHistogram = txnReaderDurationHistogram.WithLabelValues("block-merge-reader") 303 304 txnRangesSelectivityHistogram = prometheus.NewHistogramVec( 305 prometheus.HistogramOpts{ 306 Namespace: "mo", 307 Subsystem: "txn", 308 Name: "ranges_selectivity_percentage", 309 Help: "Bucketed histogram of fast ranges selectivity percentage.", 310 Buckets: prometheus.LinearBuckets(0, 0.05, 21), 311 }, []string{"type"}) 312 TxnRangesBlockSelectivityHistogram = txnRangesSelectivityHistogram.WithLabelValues("block_selectivity") 313 TxnFastRangesBlockSelectivityHistogram = txnRangesSelectivityHistogram.WithLabelValues("fast_block_selectivity") 314 TxnFastRangesZMapSelectivityHistogram = txnRangesSelectivityHistogram.WithLabelValues("fast_zm_selectivity") 315 )