Repository: pingcap/tidb
File: pkg/metrics/executor.go (Go)

Code before:
			Help:      "hard delete statement count for a soft delete table",
		})

	ActiveActiveWriteUnsafeOriginTsRowCounter = metricscommon.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "write_unsafe_origin_ts_rows_total",
			Help:      "rows written with unsafe _tidb_origin_ts column",
		})

	ActiveActiveWriteUnsafeOriginTsStmtCounter = metricscommon.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "write_unsafe_origin_ts_stmt_total",
			Help:      "stmts written with unsafe _tidb_origin_ts column",
		})

	SoftDeleteImplicitDeleteRows = metricscommon.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "softdelete_implicit_delete_rows",
			Help:      "Bucketed histogram of soft-deleted rows implicitly removed per DML statement.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 65536
		}, []string{LblSQLType})

	SoftDeleteImplicitDeleteRowsInsert = SoftDeleteImplicitDeleteRows.WithLabelValues("Insert")
	SoftDeleteImplicitDeleteRowsLoadData = SoftDeleteImplicitDeleteRows.WithLabelValues("LoadData")

	NetworkTransmissionStats = metricscommon.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "network_transmission",
			Help:      "Counter of network transmission bytes.",
		}, []string{LblType})
}


Review comment (bug):
The bucket range comment is incorrect: `prometheus.ExponentialBuckets(1, 2, 16)` produces buckets from 1 up to 32768 (then +Inf), not 65536. Please either update the comment to match the actual max bucket, or change the bucket count to 17 if you intend to cover 65536 explicitly.
```suggestion
			Buckets:   prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 32768
```

Code after:
			Help:      "hard delete statement count for a soft delete table",
		})

	ActiveActiveWriteUnsafeOriginTsRowCounter = metricscommon.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "write_unsafe_origin_ts_rows_total",
			Help:      "rows written with unsafe _tidb_origin_ts column",
		})

	ActiveActiveWriteUnsafeOriginTsStmtCounter = metricscommon.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "write_unsafe_origin_ts_stmt_total",
			Help:      "stmts written with unsafe _tidb_origin_ts column",
		})

	SoftDeleteImplicitDeleteRows = metricscommon.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "softdelete_implicit_delete_rows",
			Help:      "Bucketed histogram of soft-deleted rows implicitly removed per DML statement.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 16), // 1 ~ 32768
		}, []string{LblSQLType})

	SoftDeleteImplicitDeleteRowsInsert = SoftDeleteImplicitDeleteRows.WithLabelValues("Insert")
	SoftDeleteImplicitDeleteRowsLoadData = SoftDeleteImplicitDeleteRows.WithLabelValues("LoadData")

	NetworkTransmissionStats = metricscommon.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "network_transmission",
			Help:      "Counter of network transmission bytes.",
		}, []string{LblType})
}