// Code generated by mdatagen. DO NOT EDIT.

package metadata

import (
	"time"

	"go.opentelemetry.io/collector/component"
	"go.opentelemetry.io/collector/filter"
	"go.opentelemetry.io/collector/pdata/pcommon"
	"go.opentelemetry.io/collector/pdata/pmetric"
	"go.opentelemetry.io/collector/receiver"
)

// AttributeComponent specifies the value component attribute.
type AttributeComponent int

const (
	_ AttributeComponent = iota
	AttributeComponentTidb
	AttributeComponentTikv
	AttributeComponentPd
	AttributeComponentTiflash
)

// String returns the string representation of the AttributeComponent.
func (av AttributeComponent) String() string {
	switch av {
	case AttributeComponentTidb:
		return "tidb"
	case AttributeComponentTikv:
		return "tikv"
	case AttributeComponentPd:
		return "pd"
	case AttributeComponentTiflash:
		return "tiflash"
	}
	return ""
}

// MapAttributeComponent is a helper map of string to AttributeComponent attribute value.
var MapAttributeComponent = map[string]AttributeComponent{
	"tidb":    AttributeComponentTidb,
	"tikv":    AttributeComponentTikv,
	"pd":      AttributeComponentPd,
	"tiflash": AttributeComponentTiflash,
}

type metricTidbCloudCdcChangefeedLatency struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.cdc_changefeed_latency metric with initial data.
func (m *metricTidbCloudCdcChangefeedLatency) init() {
	m.data.SetName("tidb_cloud.cdc_changefeed_latency")
	m.data.SetDescription("The checkpoint ts lag of a changefeed's owner.")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudCdcChangefeedLatency) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("changefeed_id", changefeedIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudCdcChangefeedLatency) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudCdcChangefeedLatency) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudCdcChangefeedLatency(cfg MetricConfig) metricTidbCloudCdcChangefeedLatency {
	m := metricTidbCloudCdcChangefeedLatency{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudCdcChangefeedReplicaRows struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.cdc_changefeed_replica_rows metric with initial data.
func (m *metricTidbCloudCdcChangefeedReplicaRows) init() {
	m.data.SetName("tidb_cloud.cdc_changefeed_replica_rows")
	m.data.SetDescription("The number of replica rows that ChangeFeed writes to the downstream per second.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudCdcChangefeedReplicaRows) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("changefeed_id", changefeedIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudCdcChangefeedReplicaRows) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudCdcChangefeedReplicaRows) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudCdcChangefeedReplicaRows(cfg MetricConfig) metricTidbCloudCdcChangefeedReplicaRows {
	m := metricTidbCloudCdcChangefeedReplicaRows{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudCdcChangefeedResolvedTsLag struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.cdc_changefeed_resolved_ts_lag metric with initial data.
func (m *metricTidbCloudCdcChangefeedResolvedTsLag) init() {
	m.data.SetName("tidb_cloud.cdc_changefeed_resolved_ts_lag")
	m.data.SetDescription("The resolved ts lag of a changefeed's owner.")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudCdcChangefeedResolvedTsLag) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("changefeed_id", changefeedIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudCdcChangefeedResolvedTsLag) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudCdcChangefeedResolvedTsLag) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudCdcChangefeedResolvedTsLag(cfg MetricConfig) metricTidbCloudCdcChangefeedResolvedTsLag {
	m := metricTidbCloudCdcChangefeedResolvedTsLag{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudCdcChangefeedStatus struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.cdc_changefeed_status metric with initial data.
func (m *metricTidbCloudCdcChangefeedStatus) init() {
	m.data.SetName("tidb_cloud.cdc_changefeed_status")
	m.data.SetDescription("The status of a changefeed.")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudCdcChangefeedStatus) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("changefeed_id", changefeedIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudCdcChangefeedStatus) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudCdcChangefeedStatus) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudCdcChangefeedStatus(cfg MetricConfig) metricTidbCloudCdcChangefeedStatus {
	m := metricTidbCloudCdcChangefeedStatus{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudCdcCheckpointTs struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.cdc_checkpoint_ts metric with initial data.
func (m *metricTidbCloudCdcCheckpointTs) init() {
	m.data.SetName("tidb_cloud.cdc_checkpoint_ts")
	m.data.SetDescription("The checkpoint timestamp of a changefeed.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudCdcCheckpointTs) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("changefeed_id", changefeedIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudCdcCheckpointTs) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudCdcCheckpointTs) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudCdcCheckpointTs(cfg MetricConfig) metricTidbCloudCdcCheckpointTs {
	m := metricTidbCloudCdcCheckpointTs{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbActiveConnections struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_active_connections metric with initial data.
func (m *metricTidbCloudDbActiveConnections) init() {
	m.data.SetName("tidb_cloud.db_active_connections")
	m.data.SetDescription("The number of active connection.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbActiveConnections) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbActiveConnections) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbActiveConnections) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbActiveConnections(cfg MetricConfig) metricTidbCloudDbActiveConnections {
	m := metricTidbCloudDbActiveConnections{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbAverageQueryDuration struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_average_query_duration metric with initial data.
func (m *metricTidbCloudDbAverageQueryDuration) init() {
	m.data.SetName("tidb_cloud.db_average_query_duration")
	m.data.SetDescription("The duration between the time that the client's network request is sent to TiDB and the time that the request is returned to the client after TiDB has executed it. In general, client requests are sent in the form of SQL statements, but can also include the execution time of commands such as COM_PING, COM_SLEEP, COM_STMT_FETCH, and COM_SEND_LONG_DATA. Because TiDB supports Multi-Query, it supports sending multiple SQL statements at one time, such as select 1; select 1; select 1;. In this case, the total execution time of this query includes the execution time of all SQL statements.")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbAverageQueryDuration) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, sqlTypeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("sql_type", sqlTypeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbAverageQueryDuration) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbAverageQueryDuration) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbAverageQueryDuration(cfg MetricConfig) metricTidbCloudDbAverageQueryDuration {
	m := metricTidbCloudDbAverageQueryDuration{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbColumnarStorageUsedBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_columnar_storage_used_bytes metric with initial data.
func (m *metricTidbCloudDbColumnarStorageUsedBytes) init() {
	m.data.SetName("tidb_cloud.db_columnar_storage_used_bytes")
	m.data.SetDescription("The columnar (TiFlash) storage usage for a TiDB X cluster.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbColumnarStorageUsedBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbColumnarStorageUsedBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbColumnarStorageUsedBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbColumnarStorageUsedBytes(cfg MetricConfig) metricTidbCloudDbColumnarStorageUsedBytes {
	m := metricTidbCloudDbColumnarStorageUsedBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbCommandPerSecond struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_command_per_second metric with initial data.
func (m *metricTidbCloudDbCommandPerSecond) init() {
	m.data.SetName("tidb_cloud.db_command_per_second")
	m.data.SetDescription("The number of commands processed by TiDB per second, which is classified according to the success or failure of command execution results.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbCommandPerSecond) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbCommandPerSecond) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbCommandPerSecond) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbCommandPerSecond(cfg MetricConfig) metricTidbCloudDbCommandPerSecond {
	m := metricTidbCloudDbCommandPerSecond{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbComponentUptime struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_component_uptime metric with initial data.
func (m *metricTidbCloudDbComponentUptime) init() {
	m.data.SetName("tidb_cloud.db_component_uptime")
	m.data.SetDescription("The uptime of tidb components")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbComponentUptime) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbComponentUptime) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbComponentUptime) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbComponentUptime(cfg MetricConfig) metricTidbCloudDbComponentUptime {
	m := metricTidbCloudDbComponentUptime{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbConnections struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_connections metric with initial data.
func (m *metricTidbCloudDbConnections) init() {
	m.data.SetName("tidb_cloud.db_connections")
	m.data.SetDescription("Current number of connections in TiDB server.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbConnections) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, instanceAttributeValue string, clusterIDAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbConnections) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbConnections) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbConnections(cfg MetricConfig) metricTidbCloudDbConnections {
	m := metricTidbCloudDbConnections{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbDatabaseTime struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_database_time metric with initial data.
func (m *metricTidbCloudDbDatabaseTime) init() {
	m.data.SetName("tidb_cloud.db_database_time")
	m.data.SetDescription("A time model statistic that is the sum of all process' CPU consumption plus the sum of non-idle wait time.")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbDatabaseTime) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, sqlTypeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("sql_type", sqlTypeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbDatabaseTime) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbDatabaseTime) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbDatabaseTime(cfg MetricConfig) metricTidbCloudDbDatabaseTime {
	m := metricTidbCloudDbDatabaseTime{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbDisconnections struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_disconnections metric with initial data.
func (m *metricTidbCloudDbDisconnections) init() {
	m.data.SetName("tidb_cloud.db_disconnections")
	m.data.SetDescription("The number of clients disconnected.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbDisconnections) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, resultAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("result", resultAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbDisconnections) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbDisconnections) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbDisconnections(cfg MetricConfig) metricTidbCloudDbDisconnections {
	m := metricTidbCloudDbDisconnections{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbFailedQueries struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_failed_queries metric with initial data.
func (m *metricTidbCloudDbFailedQueries) init() {
	m.data.SetName("tidb_cloud.db_failed_queries")
	m.data.SetDescription("The statistics of error types (such as syntax errors and primary key conflicts) according to the errors occurred when executing SQL statements per second on each TiDB instance.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbFailedQueries) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbFailedQueries) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbFailedQueries) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbFailedQueries(cfg MetricConfig) metricTidbCloudDbFailedQueries {
	m := metricTidbCloudDbFailedQueries{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbFailedQueriesTotal struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_failed_queries_total metric with initial data.
func (m *metricTidbCloudDbFailedQueriesTotal) init() {
	m.data.SetName("tidb_cloud.db_failed_queries_total")
	m.data.SetDescription("The total number of execution errors.")
	m.data.SetUnit("1")
	m.data.SetEmptySum()
	m.data.Sum().SetIsMonotonic(true)
	m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityUnspecified)
	m.data.Sum().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbFailedQueriesTotal) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, typeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Sum().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbFailedQueriesTotal) updateCapacity() {
	if m.data.Sum().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Sum().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbFailedQueriesTotal) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbFailedQueriesTotal(cfg MetricConfig) metricTidbCloudDbFailedQueriesTotal {
	m := metricTidbCloudDbFailedQueriesTotal{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbKvRequestDuration struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_kv_request_duration metric with initial data.
func (m *metricTidbCloudDbKvRequestDuration) init() {
	m.data.SetName("tidb_cloud.db_kv_request_duration")
	m.data.SetDescription("TiDB KV Request Duration")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbKvRequestDuration) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbKvRequestDuration) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbKvRequestDuration) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbKvRequestDuration(cfg MetricConfig) metricTidbCloudDbKvRequestDuration {
	m := metricTidbCloudDbKvRequestDuration{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbQueriesTotal struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_queries_total metric with initial data.
func (m *metricTidbCloudDbQueriesTotal) init() {
	m.data.SetName("tidb_cloud.db_queries_total")
	m.data.SetDescription("The total number of queries.")
	m.data.SetUnit("1")
	m.data.SetEmptySum()
	m.data.Sum().SetIsMonotonic(true)
	m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityUnspecified)
	m.data.Sum().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbQueriesTotal) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, sqlTypeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Sum().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("sql_type", sqlTypeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbQueriesTotal) updateCapacity() {
	if m.data.Sum().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Sum().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbQueriesTotal) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbQueriesTotal(cfg MetricConfig) metricTidbCloudDbQueriesTotal {
	m := metricTidbCloudDbQueriesTotal{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbQueriesUsingPlanCacheOps struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_queries_using_plan_cache_ops metric with initial data.
func (m *metricTidbCloudDbQueriesUsingPlanCacheOps) init() {
	m.data.SetName("tidb_cloud.db_queries_using_plan_cache_ops")
	m.data.SetDescription("The statistics of queries using Plan Cache per second. The execution plan cache only supports the prepared statement command. If the value is 0, the execution plan cache has not been hit.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbQueriesUsingPlanCacheOps) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbQueriesUsingPlanCacheOps) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbQueriesUsingPlanCacheOps) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbQueriesUsingPlanCacheOps(cfg MetricConfig) metricTidbCloudDbQueriesUsingPlanCacheOps {
	m := metricTidbCloudDbQueriesUsingPlanCacheOps{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbQueryDurationSecondsCount struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_query_duration_seconds.count metric with initial data.
func (m *metricTidbCloudDbQueryDurationSecondsCount) init() {
	m.data.SetName("tidb_cloud.db_query_duration_seconds.count")
	m.data.SetDescription("Total number of handled queries in server")
	m.data.SetUnit("1")
	m.data.SetEmptySum()
	m.data.Sum().SetIsMonotonic(true)
	m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityUnspecified)
	m.data.Sum().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbQueryDurationSecondsCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, sqlTypeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Sum().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("sql_type", sqlTypeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbQueryDurationSecondsCount) updateCapacity() {
	if m.data.Sum().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Sum().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbQueryDurationSecondsCount) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbQueryDurationSecondsCount(cfg MetricConfig) metricTidbCloudDbQueryDurationSecondsCount {
	m := metricTidbCloudDbQueryDurationSecondsCount{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbQueryDurationSecondsSum struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_query_duration_seconds.sum metric with initial data.
func (m *metricTidbCloudDbQueryDurationSecondsSum) init() {
	m.data.SetName("tidb_cloud.db_query_duration_seconds.sum")
	m.data.SetDescription("Total number of handled queries in server")
	m.data.SetUnit("s")
	m.data.SetEmptySum()
	m.data.Sum().SetIsMonotonic(true)
	m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityUnspecified)
	m.data.Sum().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbQueryDurationSecondsSum) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, sqlTypeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Sum().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("sql_type", sqlTypeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbQueryDurationSecondsSum) updateCapacity() {
	if m.data.Sum().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Sum().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbQueryDurationSecondsSum) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbQueryDurationSecondsSum(cfg MetricConfig) metricTidbCloudDbQueryDurationSecondsSum {
	m := metricTidbCloudDbQueryDurationSecondsSum{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbQueryPerSecond struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_query_per_second metric with initial data.
func (m *metricTidbCloudDbQueryPerSecond) init() {
	m.data.SetName("tidb_cloud.db_query_per_second")
	m.data.SetDescription("The number of SQL statements executed per second on all TiDB instances, which is counted according to SELECT, INSERT, UPDATE, and other types of statements.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbQueryPerSecond) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbQueryPerSecond) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbQueryPerSecond) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbQueryPerSecond(cfg MetricConfig) metricTidbCloudDbQueryPerSecond {
	m := metricTidbCloudDbQueryPerSecond{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbRowStorageUsedBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_row_storage_used_bytes metric with initial data.
func (m *metricTidbCloudDbRowStorageUsedBytes) init() {
	m.data.SetName("tidb_cloud.db_row_storage_used_bytes")
	m.data.SetDescription("The row-based (TiKV) storage usage for a TiDB X cluster.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbRowStorageUsedBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbRowStorageUsedBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbRowStorageUsedBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbRowStorageUsedBytes(cfg MetricConfig) metricTidbCloudDbRowStorageUsedBytes {
	m := metricTidbCloudDbRowStorageUsedBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbTotalConnection struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_total_connection metric with initial data.
func (m *metricTidbCloudDbTotalConnection) init() {
	m.data.SetName("tidb_cloud.db_total_connection")
	m.data.SetDescription("The number of current connection")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbTotalConnection) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbTotalConnection) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbTotalConnection) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbTotalConnection(cfg MetricConfig) metricTidbCloudDbTotalConnection {
	m := metricTidbCloudDbTotalConnection{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDbTransactionPerSecond struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.db_transaction_per_second metric with initial data.
func (m *metricTidbCloudDbTransactionPerSecond) init() {
	m.data.SetName("tidb_cloud.db_transaction_per_second")
	m.data.SetDescription("The number of transactions executed per second.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDbTransactionPerSecond) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, txnModeAttributeValue string, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("txn_mode", txnModeAttributeValue)
	dp.Attributes().PutStr("type", typeAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDbTransactionPerSecond) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDbTransactionPerSecond) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDbTransactionPerSecond(cfg MetricConfig) metricTidbCloudDbTransactionPerSecond {
	m := metricTidbCloudDbTransactionPerSecond{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDmRelayReadErrorCount struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.dm_relay_read_error_count metric with initial data.
func (m *metricTidbCloudDmRelayReadErrorCount) init() {
	m.data.SetName("tidb_cloud.dm_relay_read_error_count")
	m.data.SetDescription("Task State")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDmRelayReadErrorCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("task", taskAttributeValue)
	dp.Attributes().PutStr("job_id", jobIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDmRelayReadErrorCount) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDmRelayReadErrorCount) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDmRelayReadErrorCount(cfg MetricConfig) metricTidbCloudDmRelayReadErrorCount {
	m := metricTidbCloudDmRelayReadErrorCount{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDmSyncerReplicationLagBucket struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.dm_syncer_replication_lag_bucket metric with initial data.
func (m *metricTidbCloudDmSyncerReplicationLagBucket) init() {
	m.data.SetName("tidb_cloud.dm_syncer_replication_lag_bucket")
	m.data.SetDescription("Task State")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDmSyncerReplicationLagBucket) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("task", taskAttributeValue)
	dp.Attributes().PutStr("job_id", jobIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDmSyncerReplicationLagBucket) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDmSyncerReplicationLagBucket) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDmSyncerReplicationLagBucket(cfg MetricConfig) metricTidbCloudDmSyncerReplicationLagBucket {
	m := metricTidbCloudDmSyncerReplicationLagBucket{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDmSyncerReplicationLagGauge struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.dm_syncer_replication_lag_gauge metric with initial data.
func (m *metricTidbCloudDmSyncerReplicationLagGauge) init() {
	m.data.SetName("tidb_cloud.dm_syncer_replication_lag_gauge")
	m.data.SetDescription("Task State")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDmSyncerReplicationLagGauge) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("task", taskAttributeValue)
	dp.Attributes().PutStr("job_id", jobIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDmSyncerReplicationLagGauge) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDmSyncerReplicationLagGauge) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDmSyncerReplicationLagGauge(cfg MetricConfig) metricTidbCloudDmSyncerReplicationLagGauge {
	m := metricTidbCloudDmSyncerReplicationLagGauge{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudDmTaskState struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.dm_task_state metric with initial data.
func (m *metricTidbCloudDmTaskState) init() {
	m.data.SetName("tidb_cloud.dm_task_state")
	m.data.SetDescription("Task State")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudDmTaskState) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("task", taskAttributeValue)
	dp.Attributes().PutStr("job_id", jobIDAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudDmTaskState) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudDmTaskState) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudDmTaskState(cfg MetricConfig) metricTidbCloudDmTaskState {
	m := metricTidbCloudDmTaskState{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeCPUCapacityCores struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_cpu_capacity_cores metric with initial data.
func (m *metricTidbCloudNodeCPUCapacityCores) init() {
	m.data.SetName("tidb_cloud.node_cpu_capacity_cores")
	m.data.SetDescription("The capacity cores of TiDB/TiKV/TiFlash nodes.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeCPUCapacityCores) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeCPUCapacityCores) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeCPUCapacityCores) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeCPUCapacityCores(cfg MetricConfig) metricTidbCloudNodeCPUCapacityCores {
	m := metricTidbCloudNodeCPUCapacityCores{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeCPUSecondsTotal struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_cpu_seconds_total metric with initial data.
func (m *metricTidbCloudNodeCPUSecondsTotal) init() {
	m.data.SetName("tidb_cloud.node_cpu_seconds_total")
	m.data.SetDescription("The CPU usage of TiDB/TiKV/TiFlash nodes.")
	m.data.SetUnit("s")
	m.data.SetEmptySum()
	m.data.Sum().SetIsMonotonic(true)
	m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityUnspecified)
	m.data.Sum().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeCPUSecondsTotal) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Sum().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeCPUSecondsTotal) updateCapacity() {
	if m.data.Sum().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Sum().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeCPUSecondsTotal) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeCPUSecondsTotal(cfg MetricConfig) metricTidbCloudNodeCPUSecondsTotal {
	m := metricTidbCloudNodeCPUSecondsTotal{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeCPUSecondsTotalRate struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_cpu_seconds_total_rate metric with initial data.
func (m *metricTidbCloudNodeCPUSecondsTotalRate) init() {
	m.data.SetName("tidb_cloud.node_cpu_seconds_total_rate")
	m.data.SetDescription("The CPU usage rate of TiDB/TiKV/TiFlash nodes.")
	m.data.SetUnit("s")
	m.data.SetEmptySum()
	m.data.Sum().SetIsMonotonic(true)
	m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityUnspecified)
	m.data.Sum().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeCPUSecondsTotalRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Sum().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeCPUSecondsTotalRate) updateCapacity() {
	if m.data.Sum().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Sum().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeCPUSecondsTotalRate) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeCPUSecondsTotalRate(cfg MetricConfig) metricTidbCloudNodeCPUSecondsTotalRate {
	m := metricTidbCloudNodeCPUSecondsTotalRate{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeDiskReadLatency struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_disk_read_latency metric with initial data.
func (m *metricTidbCloudNodeDiskReadLatency) init() {
	m.data.SetName("tidb_cloud.node_disk_read_latency")
	m.data.SetDescription("Node disk read latency")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeDiskReadLatency) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string, deviceAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
	dp.Attributes().PutStr("device", deviceAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeDiskReadLatency) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeDiskReadLatency) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeDiskReadLatency(cfg MetricConfig) metricTidbCloudNodeDiskReadLatency {
	m := metricTidbCloudNodeDiskReadLatency{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeDiskWriteLatency struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_disk_write_latency metric with initial data.
func (m *metricTidbCloudNodeDiskWriteLatency) init() {
	m.data.SetName("tidb_cloud.node_disk_write_latency")
	m.data.SetDescription("Node disk write latency")
	m.data.SetUnit("s")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeDiskWriteLatency) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string, deviceAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
	dp.Attributes().PutStr("device", deviceAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeDiskWriteLatency) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeDiskWriteLatency) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeDiskWriteLatency(cfg MetricConfig) metricTidbCloudNodeDiskWriteLatency {
	m := metricTidbCloudNodeDiskWriteLatency{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeMemoryAvailableBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_memory_available_bytes metric with initial data.
func (m *metricTidbCloudNodeMemoryAvailableBytes) init() {
	m.data.SetName("tidb_cloud.node_memory_available_bytes")
	m.data.SetDescription("The memory capacity bytes of TiDB/TiKV/TiFlash nodes.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeMemoryAvailableBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeMemoryAvailableBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeMemoryAvailableBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeMemoryAvailableBytes(cfg MetricConfig) metricTidbCloudNodeMemoryAvailableBytes {
	m := metricTidbCloudNodeMemoryAvailableBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeMemoryCapacityBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_memory_capacity_bytes metric with initial data.
func (m *metricTidbCloudNodeMemoryCapacityBytes) init() {
	m.data.SetName("tidb_cloud.node_memory_capacity_bytes")
	m.data.SetDescription("The memory capacity bytes of TiDB/TiKV/TiFlash nodes.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeMemoryCapacityBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeMemoryCapacityBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeMemoryCapacityBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeMemoryCapacityBytes(cfg MetricConfig) metricTidbCloudNodeMemoryCapacityBytes {
	m := metricTidbCloudNodeMemoryCapacityBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeMemoryUsedBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_memory_used_bytes metric with initial data.
func (m *metricTidbCloudNodeMemoryUsedBytes) init() {
	m.data.SetName("tidb_cloud.node_memory_used_bytes")
	m.data.SetDescription("The used memory bytes of TiDB/TiKV/TiFlash nodes.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeMemoryUsedBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeMemoryUsedBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeMemoryUsedBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeMemoryUsedBytes(cfg MetricConfig) metricTidbCloudNodeMemoryUsedBytes {
	m := metricTidbCloudNodeMemoryUsedBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeStorageAvailableBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_storage_available_bytes metric with initial data.
func (m *metricTidbCloudNodeStorageAvailableBytes) init() {
	m.data.SetName("tidb_cloud.node_storage_available_bytes")
	m.data.SetDescription("The disk available bytes of TiKV/TiFlash nodes.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeStorageAvailableBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeStorageAvailableBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeStorageAvailableBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeStorageAvailableBytes(cfg MetricConfig) metricTidbCloudNodeStorageAvailableBytes {
	m := metricTidbCloudNodeStorageAvailableBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeStorageCapacityBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_storage_capacity_bytes metric with initial data.
func (m *metricTidbCloudNodeStorageCapacityBytes) init() {
	m.data.SetName("tidb_cloud.node_storage_capacity_bytes")
	m.data.SetDescription("The disk capacity bytes of TiKV/TiFlash nodes.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeStorageCapacityBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeStorageCapacityBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeStorageCapacityBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeStorageCapacityBytes(cfg MetricConfig) metricTidbCloudNodeStorageCapacityBytes {
	m := metricTidbCloudNodeStorageCapacityBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudNodeStorageUsedBytes struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.node_storage_used_bytes metric with initial data.
func (m *metricTidbCloudNodeStorageUsedBytes) init() {
	m.data.SetName("tidb_cloud.node_storage_used_bytes")
	m.data.SetDescription("The disk usage bytes of TiKV/TiFlash nodes.")
	m.data.SetUnit("By")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudNodeStorageUsedBytes) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetIntValue(val)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("cluster_id", clusterIDAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("component", componentAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudNodeStorageUsedBytes) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudNodeStorageUsedBytes) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudNodeStorageUsedBytes(cfg MetricConfig) metricTidbCloudNodeStorageUsedBytes {
	m := metricTidbCloudNodeStorageUsedBytes{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudResourceManagerResourceUnitReadRequestUnit struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.resource_manager_resource_unit_read_request_unit metric with initial data.
func (m *metricTidbCloudResourceManagerResourceUnitReadRequestUnit) init() {
	m.data.SetName("tidb_cloud.resource_manager_resource_unit_read_request_unit")
	m.data.SetDescription("The resource manager read request.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudResourceManagerResourceUnitReadRequestUnit) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, resourceGroupAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("resource_group", resourceGroupAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudResourceManagerResourceUnitReadRequestUnit) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudResourceManagerResourceUnitReadRequestUnit) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudResourceManagerResourceUnitReadRequestUnit(cfg MetricConfig) metricTidbCloudResourceManagerResourceUnitReadRequestUnit {
	m := metricTidbCloudResourceManagerResourceUnitReadRequestUnit{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudResourceManagerResourceRequestUnitTotal struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.resource_manager_resource_request_unit_total metric with initial data.
func (m *metricTidbCloudResourceManagerResourceRequestUnitTotal) init() {
	m.data.SetName("tidb_cloud.resource_manager_resource_request_unit_total")
	m.data.SetDescription("The resource manager request unit total.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudResourceManagerResourceRequestUnitTotal) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, resourceGroupAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	if resourceGroupAttributeValue != "" {
		dp.Attributes().PutStr("resource_group", resourceGroupAttributeValue)
	}
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudResourceManagerResourceRequestUnitTotal) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudResourceManagerResourceRequestUnitTotal) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudResourceManagerResourceRequestUnitTotal(cfg MetricConfig) metricTidbCloudResourceManagerResourceRequestUnitTotal {
	m := metricTidbCloudResourceManagerResourceRequestUnitTotal{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

type metricTidbCloudResourceManagerResourceUnitWriteRequestUnit struct {
	data     pmetric.Metric // data buffer for generated metric.
	config   MetricConfig   // metric config provided by user.
	capacity int            // max observed number of data points added to the metric.
}

// init fills tidb_cloud.resource_manager_resource_unit_write_request_unit metric with initial data.
func (m *metricTidbCloudResourceManagerResourceUnitWriteRequestUnit) init() {
	m.data.SetName("tidb_cloud.resource_manager_resource_unit_write_request_unit")
	m.data.SetDescription("The resource manager write request.")
	m.data.SetUnit("1")
	m.data.SetEmptyGauge()
	m.data.Gauge().DataPoints().EnsureCapacity(m.capacity)
}

func (m *metricTidbCloudResourceManagerResourceUnitWriteRequestUnit) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, resourceGroupAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	if !m.config.Enabled {
		return
	}
	dp := m.data.Gauge().DataPoints().AppendEmpty()
	dp.SetStartTimestamp(start)
	dp.SetTimestamp(ts)
	dp.SetDoubleValue(val)
	dp.Attributes().PutStr("resource_group", resourceGroupAttributeValue)
	dp.Attributes().PutStr("cluster_name", clusterNameAttributeValue)
	dp.Attributes().PutStr("instance", instanceAttributeValue)
	dp.Attributes().PutStr("project_name", projectNameAttributeValue)
}

// updateCapacity saves max length of data point slices that will be used for the slice capacity.
func (m *metricTidbCloudResourceManagerResourceUnitWriteRequestUnit) updateCapacity() {
	if m.data.Gauge().DataPoints().Len() > m.capacity {
		m.capacity = m.data.Gauge().DataPoints().Len()
	}
}

// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points.
func (m *metricTidbCloudResourceManagerResourceUnitWriteRequestUnit) emit(metrics pmetric.MetricSlice) {
	if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 {
		m.updateCapacity()
		m.data.MoveTo(metrics.AppendEmpty())
		m.init()
	}
}

func newMetricTidbCloudResourceManagerResourceUnitWriteRequestUnit(cfg MetricConfig) metricTidbCloudResourceManagerResourceUnitWriteRequestUnit {
	m := metricTidbCloudResourceManagerResourceUnitWriteRequestUnit{config: cfg}
	if cfg.Enabled {
		m.data = pmetric.NewMetric()
		m.init()
	}
	return m
}

// MetricsBuilder provides an interface for scrapers to report metrics while taking care of all the transformations
// required to produce metric representation defined in metadata and user config.
type MetricsBuilder struct {
	config                                                     MetricsBuilderConfig // config of the metrics builder.
	startTime                                                  pcommon.Timestamp    // start time that will be applied to all recorded data points.
	metricsCapacity                                            int                  // maximum observed number of metrics per resource.
	metricsBuffer                                              pmetric.Metrics      // accumulates metrics data before emitting.
	buildInfo                                                  component.BuildInfo  // contains version information.
	resourceAttributeIncludeFilter                             map[string]filter.Filter
	resourceAttributeExcludeFilter                             map[string]filter.Filter
	metricTidbCloudCdcChangefeedLatency                        metricTidbCloudCdcChangefeedLatency
	metricTidbCloudCdcChangefeedReplicaRows                    metricTidbCloudCdcChangefeedReplicaRows
	metricTidbCloudCdcChangefeedResolvedTsLag                  metricTidbCloudCdcChangefeedResolvedTsLag
	metricTidbCloudCdcChangefeedStatus                         metricTidbCloudCdcChangefeedStatus
	metricTidbCloudCdcCheckpointTs                             metricTidbCloudCdcCheckpointTs
	metricTidbCloudDbActiveConnections                         metricTidbCloudDbActiveConnections
	metricTidbCloudDbAverageQueryDuration                      metricTidbCloudDbAverageQueryDuration
	metricTidbCloudDbColumnarStorageUsedBytes                  metricTidbCloudDbColumnarStorageUsedBytes
	metricTidbCloudDbCommandPerSecond                          metricTidbCloudDbCommandPerSecond
	metricTidbCloudDbComponentUptime                           metricTidbCloudDbComponentUptime
	metricTidbCloudDbConnections                               metricTidbCloudDbConnections
	metricTidbCloudDbDatabaseTime                              metricTidbCloudDbDatabaseTime
	metricTidbCloudDbDisconnections                            metricTidbCloudDbDisconnections
	metricTidbCloudDbFailedQueries                             metricTidbCloudDbFailedQueries
	metricTidbCloudDbFailedQueriesTotal                        metricTidbCloudDbFailedQueriesTotal
	metricTidbCloudDbKvRequestDuration                         metricTidbCloudDbKvRequestDuration
	metricTidbCloudDbQueriesTotal                              metricTidbCloudDbQueriesTotal
	metricTidbCloudDbQueriesUsingPlanCacheOps                  metricTidbCloudDbQueriesUsingPlanCacheOps
	metricTidbCloudDbQueryDurationSecondsCount                 metricTidbCloudDbQueryDurationSecondsCount
	metricTidbCloudDbQueryDurationSecondsSum                   metricTidbCloudDbQueryDurationSecondsSum
	metricTidbCloudDbQueryPerSecond                            metricTidbCloudDbQueryPerSecond
	metricTidbCloudDbRowStorageUsedBytes                       metricTidbCloudDbRowStorageUsedBytes
	metricTidbCloudDbTotalConnection                           metricTidbCloudDbTotalConnection
	metricTidbCloudDbTransactionPerSecond                      metricTidbCloudDbTransactionPerSecond
	metricTidbCloudDmRelayReadErrorCount                       metricTidbCloudDmRelayReadErrorCount
	metricTidbCloudDmSyncerReplicationLagBucket                metricTidbCloudDmSyncerReplicationLagBucket
	metricTidbCloudDmSyncerReplicationLagGauge                 metricTidbCloudDmSyncerReplicationLagGauge
	metricTidbCloudDmTaskState                                 metricTidbCloudDmTaskState
	metricTidbCloudNodeCPUCapacityCores                        metricTidbCloudNodeCPUCapacityCores
	metricTidbCloudNodeCPUSecondsTotal                         metricTidbCloudNodeCPUSecondsTotal
	metricTidbCloudNodeCPUSecondsTotalRate                     metricTidbCloudNodeCPUSecondsTotalRate
	metricTidbCloudNodeDiskReadLatency                         metricTidbCloudNodeDiskReadLatency
	metricTidbCloudNodeDiskWriteLatency                        metricTidbCloudNodeDiskWriteLatency
	metricTidbCloudNodeMemoryAvailableBytes                    metricTidbCloudNodeMemoryAvailableBytes
	metricTidbCloudNodeMemoryCapacityBytes                     metricTidbCloudNodeMemoryCapacityBytes
	metricTidbCloudNodeMemoryUsedBytes                         metricTidbCloudNodeMemoryUsedBytes
	metricTidbCloudNodeStorageAvailableBytes                   metricTidbCloudNodeStorageAvailableBytes
	metricTidbCloudNodeStorageCapacityBytes                    metricTidbCloudNodeStorageCapacityBytes
	metricTidbCloudNodeStorageUsedBytes                        metricTidbCloudNodeStorageUsedBytes
	metricTidbCloudResourceManagerResourceRequestUnitTotal     metricTidbCloudResourceManagerResourceRequestUnitTotal
	metricTidbCloudResourceManagerResourceUnitReadRequestUnit  metricTidbCloudResourceManagerResourceUnitReadRequestUnit
	metricTidbCloudResourceManagerResourceUnitWriteRequestUnit metricTidbCloudResourceManagerResourceUnitWriteRequestUnit
}

// MetricBuilderOption applies changes to default metrics builder.
type MetricBuilderOption interface {
	apply(*MetricsBuilder)
}

type metricBuilderOptionFunc func(mb *MetricsBuilder)

func (mbof metricBuilderOptionFunc) apply(mb *MetricsBuilder) {
	mbof(mb)
}

// WithStartTime sets startTime on the metrics builder.
func WithStartTime(startTime pcommon.Timestamp) MetricBuilderOption {
	return metricBuilderOptionFunc(func(mb *MetricsBuilder) {
		mb.startTime = startTime
	})
}

func NewMetricsBuilder(mbc MetricsBuilderConfig, settings receiver.Settings, options ...MetricBuilderOption) *MetricsBuilder {
	mb := &MetricsBuilder{
		config:                                  mbc,
		startTime:                               pcommon.NewTimestampFromTime(time.Now()),
		metricsBuffer:                           pmetric.NewMetrics(),
		buildInfo:                               settings.BuildInfo,
		metricTidbCloudCdcChangefeedLatency:     newMetricTidbCloudCdcChangefeedLatency(mbc.Metrics.TidbCloudCdcChangefeedLatency),
		metricTidbCloudCdcChangefeedReplicaRows: newMetricTidbCloudCdcChangefeedReplicaRows(mbc.Metrics.TidbCloudCdcChangefeedReplicaRows),
		metricTidbCloudCdcChangefeedResolvedTsLag:                  newMetricTidbCloudCdcChangefeedResolvedTsLag(mbc.Metrics.TidbCloudCdcChangefeedResolvedTsLag),
		metricTidbCloudCdcChangefeedStatus:                         newMetricTidbCloudCdcChangefeedStatus(mbc.Metrics.TidbCloudCdcChangefeedStatus),
		metricTidbCloudCdcCheckpointTs:                             newMetricTidbCloudCdcCheckpointTs(mbc.Metrics.TidbCloudCdcCheckpointTs),
		metricTidbCloudDbActiveConnections:                         newMetricTidbCloudDbActiveConnections(mbc.Metrics.TidbCloudDbActiveConnections),
		metricTidbCloudDbAverageQueryDuration:                      newMetricTidbCloudDbAverageQueryDuration(mbc.Metrics.TidbCloudDbAverageQueryDuration),
		metricTidbCloudDbColumnarStorageUsedBytes:                  newMetricTidbCloudDbColumnarStorageUsedBytes(mbc.Metrics.TidbCloudDbColumnarStorageUsedBytes),
		metricTidbCloudDbCommandPerSecond:                          newMetricTidbCloudDbCommandPerSecond(mbc.Metrics.TidbCloudDbCommandPerSecond),
		metricTidbCloudDbComponentUptime:                           newMetricTidbCloudDbComponentUptime(mbc.Metrics.TidbCloudDbComponentUptime),
		metricTidbCloudDbConnections:                               newMetricTidbCloudDbConnections(mbc.Metrics.TidbCloudDbConnections),
		metricTidbCloudDbDatabaseTime:                              newMetricTidbCloudDbDatabaseTime(mbc.Metrics.TidbCloudDbDatabaseTime),
		metricTidbCloudDbDisconnections:                            newMetricTidbCloudDbDisconnections(mbc.Metrics.TidbCloudDbDisconnections),
		metricTidbCloudDbFailedQueries:                             newMetricTidbCloudDbFailedQueries(mbc.Metrics.TidbCloudDbFailedQueries),
		metricTidbCloudDbFailedQueriesTotal:                        newMetricTidbCloudDbFailedQueriesTotal(mbc.Metrics.TidbCloudDbFailedQueriesTotal),
		metricTidbCloudDbKvRequestDuration:                         newMetricTidbCloudDbKvRequestDuration(mbc.Metrics.TidbCloudDbKvRequestDuration),
		metricTidbCloudDbQueriesTotal:                              newMetricTidbCloudDbQueriesTotal(mbc.Metrics.TidbCloudDbQueriesTotal),
		metricTidbCloudDbQueriesUsingPlanCacheOps:                  newMetricTidbCloudDbQueriesUsingPlanCacheOps(mbc.Metrics.TidbCloudDbQueriesUsingPlanCacheOps),
		metricTidbCloudDbQueryDurationSecondsCount:                 newMetricTidbCloudDbQueryDurationSecondsCount(mbc.Metrics.TidbCloudDbQueryDurationSecondsCount),
		metricTidbCloudDbQueryDurationSecondsSum:                   newMetricTidbCloudDbQueryDurationSecondsSum(mbc.Metrics.TidbCloudDbQueryDurationSecondsSum),
		metricTidbCloudDbQueryPerSecond:                            newMetricTidbCloudDbQueryPerSecond(mbc.Metrics.TidbCloudDbQueryPerSecond),
		metricTidbCloudDbRowStorageUsedBytes:                       newMetricTidbCloudDbRowStorageUsedBytes(mbc.Metrics.TidbCloudDbRowStorageUsedBytes),
		metricTidbCloudDbTotalConnection:                           newMetricTidbCloudDbTotalConnection(mbc.Metrics.TidbCloudDbTotalConnection),
		metricTidbCloudDbTransactionPerSecond:                      newMetricTidbCloudDbTransactionPerSecond(mbc.Metrics.TidbCloudDbTransactionPerSecond),
		metricTidbCloudDmRelayReadErrorCount:                       newMetricTidbCloudDmRelayReadErrorCount(mbc.Metrics.TidbCloudDmRelayReadErrorCount),
		metricTidbCloudDmSyncerReplicationLagBucket:                newMetricTidbCloudDmSyncerReplicationLagBucket(mbc.Metrics.TidbCloudDmSyncerReplicationLagBucket),
		metricTidbCloudDmSyncerReplicationLagGauge:                 newMetricTidbCloudDmSyncerReplicationLagGauge(mbc.Metrics.TidbCloudDmSyncerReplicationLagGauge),
		metricTidbCloudDmTaskState:                                 newMetricTidbCloudDmTaskState(mbc.Metrics.TidbCloudDmTaskState),
		metricTidbCloudNodeCPUCapacityCores:                        newMetricTidbCloudNodeCPUCapacityCores(mbc.Metrics.TidbCloudNodeCPUCapacityCores),
		metricTidbCloudNodeCPUSecondsTotal:                         newMetricTidbCloudNodeCPUSecondsTotal(mbc.Metrics.TidbCloudNodeCPUSecondsTotal),
		metricTidbCloudNodeCPUSecondsTotalRate:                     newMetricTidbCloudNodeCPUSecondsTotalRate(mbc.Metrics.TidbCloudNodeCPUSecondsTotalRate),
		metricTidbCloudNodeDiskReadLatency:                         newMetricTidbCloudNodeDiskReadLatency(mbc.Metrics.TidbCloudNodeDiskReadLatency),
		metricTidbCloudNodeDiskWriteLatency:                        newMetricTidbCloudNodeDiskWriteLatency(mbc.Metrics.TidbCloudNodeDiskWriteLatency),
		metricTidbCloudNodeMemoryAvailableBytes:                    newMetricTidbCloudNodeMemoryAvailableBytes(mbc.Metrics.TidbCloudNodeMemoryAvailableBytes),
		metricTidbCloudNodeMemoryCapacityBytes:                     newMetricTidbCloudNodeMemoryCapacityBytes(mbc.Metrics.TidbCloudNodeMemoryCapacityBytes),
		metricTidbCloudNodeMemoryUsedBytes:                         newMetricTidbCloudNodeMemoryUsedBytes(mbc.Metrics.TidbCloudNodeMemoryUsedBytes),
		metricTidbCloudNodeStorageAvailableBytes:                   newMetricTidbCloudNodeStorageAvailableBytes(mbc.Metrics.TidbCloudNodeStorageAvailableBytes),
		metricTidbCloudNodeStorageCapacityBytes:                    newMetricTidbCloudNodeStorageCapacityBytes(mbc.Metrics.TidbCloudNodeStorageCapacityBytes),
		metricTidbCloudNodeStorageUsedBytes:                        newMetricTidbCloudNodeStorageUsedBytes(mbc.Metrics.TidbCloudNodeStorageUsedBytes),
		metricTidbCloudResourceManagerResourceRequestUnitTotal:     newMetricTidbCloudResourceManagerResourceRequestUnitTotal(mbc.Metrics.TidbCloudResourceManagerResourceRequestUnitTotal),
		metricTidbCloudResourceManagerResourceUnitReadRequestUnit:  newMetricTidbCloudResourceManagerResourceUnitReadRequestUnit(mbc.Metrics.TidbCloudResourceManagerResourceUnitReadRequestUnit),
		metricTidbCloudResourceManagerResourceUnitWriteRequestUnit: newMetricTidbCloudResourceManagerResourceUnitWriteRequestUnit(mbc.Metrics.TidbCloudResourceManagerResourceUnitWriteRequestUnit),
		resourceAttributeIncludeFilter:                             make(map[string]filter.Filter),
		resourceAttributeExcludeFilter:                             make(map[string]filter.Filter),
	}
	if mbc.ResourceAttributes.ClusterID.MetricsInclude != nil {
		mb.resourceAttributeIncludeFilter["cluster_id"] = filter.CreateFilter(mbc.ResourceAttributes.ClusterID.MetricsInclude)
	}
	if mbc.ResourceAttributes.ClusterID.MetricsExclude != nil {
		mb.resourceAttributeExcludeFilter["cluster_id"] = filter.CreateFilter(mbc.ResourceAttributes.ClusterID.MetricsExclude)
	}
	if mbc.ResourceAttributes.ClusterName.MetricsInclude != nil {
		mb.resourceAttributeIncludeFilter["cluster_name"] = filter.CreateFilter(mbc.ResourceAttributes.ClusterName.MetricsInclude)
	}
	if mbc.ResourceAttributes.ClusterName.MetricsExclude != nil {
		mb.resourceAttributeExcludeFilter["cluster_name"] = filter.CreateFilter(mbc.ResourceAttributes.ClusterName.MetricsExclude)
	}
	if mbc.ResourceAttributes.ProjectID.MetricsInclude != nil {
		mb.resourceAttributeIncludeFilter["project_id"] = filter.CreateFilter(mbc.ResourceAttributes.ProjectID.MetricsInclude)
	}
	if mbc.ResourceAttributes.ProjectID.MetricsExclude != nil {
		mb.resourceAttributeExcludeFilter["project_id"] = filter.CreateFilter(mbc.ResourceAttributes.ProjectID.MetricsExclude)
	}
	if mbc.ResourceAttributes.ProjectName.MetricsInclude != nil {
		mb.resourceAttributeIncludeFilter["project_name"] = filter.CreateFilter(mbc.ResourceAttributes.ProjectName.MetricsInclude)
	}
	if mbc.ResourceAttributes.ProjectName.MetricsExclude != nil {
		mb.resourceAttributeExcludeFilter["project_name"] = filter.CreateFilter(mbc.ResourceAttributes.ProjectName.MetricsExclude)
	}
	if mbc.ResourceAttributes.ServicePlan.MetricsInclude != nil {
		mb.resourceAttributeIncludeFilter["service_plan"] = filter.CreateFilter(mbc.ResourceAttributes.ServicePlan.MetricsInclude)
	}
	if mbc.ResourceAttributes.ServicePlan.MetricsExclude != nil {
		mb.resourceAttributeExcludeFilter["service_plan"] = filter.CreateFilter(mbc.ResourceAttributes.ServicePlan.MetricsExclude)
	}

	for _, op := range options {
		op.apply(mb)
	}
	return mb
}

// NewResourceBuilder returns a new resource builder that should be used to build a resource associated with for the emitted metrics.
func (mb *MetricsBuilder) NewResourceBuilder() *ResourceBuilder {
	return NewResourceBuilder(mb.config.ResourceAttributes)
}

// updateCapacity updates max length of metrics and resource attributes that will be used for the slice capacity.
func (mb *MetricsBuilder) updateCapacity(rm pmetric.ResourceMetrics) {
	if mb.metricsCapacity < rm.ScopeMetrics().At(0).Metrics().Len() {
		mb.metricsCapacity = rm.ScopeMetrics().At(0).Metrics().Len()
	}
}

// ResourceMetricsOption applies changes to provided resource metrics.
type ResourceMetricsOption interface {
	apply(pmetric.ResourceMetrics)
}

type resourceMetricsOptionFunc func(pmetric.ResourceMetrics)

func (rmof resourceMetricsOptionFunc) apply(rm pmetric.ResourceMetrics) {
	rmof(rm)
}

// WithResource sets the provided resource on the emitted ResourceMetrics.
// It's recommended to use ResourceBuilder to create the resource.
func WithResource(res pcommon.Resource) ResourceMetricsOption {
	return resourceMetricsOptionFunc(func(rm pmetric.ResourceMetrics) {
		res.CopyTo(rm.Resource())
	})
}

// WithStartTimeOverride overrides start time for all the resource metrics data points.
// This option should be only used if different start time has to be set on metrics coming from different resources.
func WithStartTimeOverride(start pcommon.Timestamp) ResourceMetricsOption {
	return resourceMetricsOptionFunc(func(rm pmetric.ResourceMetrics) {
		var dps pmetric.NumberDataPointSlice
		metrics := rm.ScopeMetrics().At(0).Metrics()
		for i := 0; i < metrics.Len(); i++ {
			switch metrics.At(i).Type() {
			case pmetric.MetricTypeGauge:
				dps = metrics.At(i).Gauge().DataPoints()
			case pmetric.MetricTypeSum:
				dps = metrics.At(i).Sum().DataPoints()
			}
			for j := 0; j < dps.Len(); j++ {
				dps.At(j).SetStartTimestamp(start)
			}
		}
	})
}

// EmitForResource saves all the generated metrics under a new resource and updates the internal state to be ready for
// recording another set of data points as part of another resource. This function can be helpful when one scraper
// needs to emit metrics from several resources. Otherwise calling this function is not required,
// just `Emit` function can be called instead.
// Resource attributes should be provided as ResourceMetricsOption arguments.
func (mb *MetricsBuilder) EmitForResource(options ...ResourceMetricsOption) {
	rm := pmetric.NewResourceMetrics()
	ils := rm.ScopeMetrics().AppendEmpty()
	ils.Scope().SetName("github.com/tidbcloud/metrics-integration/pipeline")
	ils.Scope().SetVersion(mb.buildInfo.Version)
	ils.Metrics().EnsureCapacity(mb.metricsCapacity)
	mb.metricTidbCloudCdcChangefeedLatency.emit(ils.Metrics())
	mb.metricTidbCloudCdcChangefeedReplicaRows.emit(ils.Metrics())
	mb.metricTidbCloudCdcChangefeedResolvedTsLag.emit(ils.Metrics())
	mb.metricTidbCloudCdcChangefeedStatus.emit(ils.Metrics())
	mb.metricTidbCloudCdcCheckpointTs.emit(ils.Metrics())
	mb.metricTidbCloudDbActiveConnections.emit(ils.Metrics())
	mb.metricTidbCloudDbAverageQueryDuration.emit(ils.Metrics())
	mb.metricTidbCloudDbColumnarStorageUsedBytes.emit(ils.Metrics())
	mb.metricTidbCloudDbCommandPerSecond.emit(ils.Metrics())
	mb.metricTidbCloudDbComponentUptime.emit(ils.Metrics())
	mb.metricTidbCloudDbConnections.emit(ils.Metrics())
	mb.metricTidbCloudDbDatabaseTime.emit(ils.Metrics())
	mb.metricTidbCloudDbDisconnections.emit(ils.Metrics())
	mb.metricTidbCloudDbFailedQueries.emit(ils.Metrics())
	mb.metricTidbCloudDbFailedQueriesTotal.emit(ils.Metrics())
	mb.metricTidbCloudDbKvRequestDuration.emit(ils.Metrics())
	mb.metricTidbCloudDbQueriesTotal.emit(ils.Metrics())
	mb.metricTidbCloudDbQueriesUsingPlanCacheOps.emit(ils.Metrics())
	mb.metricTidbCloudDbQueryDurationSecondsCount.emit(ils.Metrics())
	mb.metricTidbCloudDbQueryDurationSecondsSum.emit(ils.Metrics())
	mb.metricTidbCloudDbQueryPerSecond.emit(ils.Metrics())
	mb.metricTidbCloudDbRowStorageUsedBytes.emit(ils.Metrics())
	mb.metricTidbCloudDbTotalConnection.emit(ils.Metrics())
	mb.metricTidbCloudDbTransactionPerSecond.emit(ils.Metrics())
	mb.metricTidbCloudDmRelayReadErrorCount.emit(ils.Metrics())
	mb.metricTidbCloudDmSyncerReplicationLagBucket.emit(ils.Metrics())
	mb.metricTidbCloudDmSyncerReplicationLagGauge.emit(ils.Metrics())
	mb.metricTidbCloudDmTaskState.emit(ils.Metrics())
	mb.metricTidbCloudNodeCPUCapacityCores.emit(ils.Metrics())
	mb.metricTidbCloudNodeCPUSecondsTotal.emit(ils.Metrics())
	mb.metricTidbCloudNodeCPUSecondsTotalRate.emit(ils.Metrics())
	mb.metricTidbCloudNodeDiskReadLatency.emit(ils.Metrics())
	mb.metricTidbCloudNodeDiskWriteLatency.emit(ils.Metrics())
	mb.metricTidbCloudNodeMemoryAvailableBytes.emit(ils.Metrics())
	mb.metricTidbCloudNodeMemoryCapacityBytes.emit(ils.Metrics())
	mb.metricTidbCloudNodeMemoryUsedBytes.emit(ils.Metrics())
	mb.metricTidbCloudNodeStorageAvailableBytes.emit(ils.Metrics())
	mb.metricTidbCloudNodeStorageCapacityBytes.emit(ils.Metrics())
	mb.metricTidbCloudNodeStorageUsedBytes.emit(ils.Metrics())
	mb.metricTidbCloudResourceManagerResourceRequestUnitTotal.emit(ils.Metrics())
	mb.metricTidbCloudResourceManagerResourceUnitReadRequestUnit.emit(ils.Metrics())
	mb.metricTidbCloudResourceManagerResourceUnitWriteRequestUnit.emit(ils.Metrics())

	for _, op := range options {
		op.apply(rm)
	}
	for attr, filter := range mb.resourceAttributeIncludeFilter {
		if val, ok := rm.Resource().Attributes().Get(attr); ok && !filter.Matches(val.AsString()) {
			return
		}
	}
	for attr, filter := range mb.resourceAttributeExcludeFilter {
		if val, ok := rm.Resource().Attributes().Get(attr); ok && filter.Matches(val.AsString()) {
			return
		}
	}

	if ils.Metrics().Len() > 0 {
		mb.updateCapacity(rm)
		rm.MoveTo(mb.metricsBuffer.ResourceMetrics().AppendEmpty())
	}
}

// Emit returns all the metrics accumulated by the metrics builder and updates the internal state to be ready for
// recording another set of metrics. This function will be responsible for applying all the transformations required to
// produce metric representation defined in metadata and user config, e.g. delta or cumulative.
func (mb *MetricsBuilder) Emit(options ...ResourceMetricsOption) pmetric.Metrics {
	mb.EmitForResource(options...)
	metrics := mb.metricsBuffer
	mb.metricsBuffer = pmetric.NewMetrics()
	return metrics
}

// RecordTidbCloudCdcChangefeedLatencyDataPoint adds a data point to tidb_cloud.cdc_changefeed_latency metric.
func (mb *MetricsBuilder) RecordTidbCloudCdcChangefeedLatencyDataPoint(ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudCdcChangefeedLatency.recordDataPoint(mb.startTime, ts, val, changefeedIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudCdcChangefeedReplicaRowsDataPoint adds a data point to tidb_cloud.cdc_changefeed_replica_rows metric.
func (mb *MetricsBuilder) RecordTidbCloudCdcChangefeedReplicaRowsDataPoint(ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudCdcChangefeedReplicaRows.recordDataPoint(mb.startTime, ts, val, changefeedIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudCdcChangefeedResolvedTsLagDataPoint adds a data point to tidb_cloud.cdc_changefeed_resolved_ts_lag metric.
func (mb *MetricsBuilder) RecordTidbCloudCdcChangefeedResolvedTsLagDataPoint(ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudCdcChangefeedResolvedTsLag.recordDataPoint(mb.startTime, ts, val, changefeedIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudCdcChangefeedStatusDataPoint adds a data point to tidb_cloud.cdc_changefeed_status metric.
func (mb *MetricsBuilder) RecordTidbCloudCdcChangefeedStatusDataPoint(ts pcommon.Timestamp, val int64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudCdcChangefeedStatus.recordDataPoint(mb.startTime, ts, val, changefeedIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudCdcCheckpointTsDataPoint adds a data point to tidb_cloud.cdc_checkpoint_ts metric.
func (mb *MetricsBuilder) RecordTidbCloudCdcCheckpointTsDataPoint(ts pcommon.Timestamp, val float64, changefeedIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudCdcCheckpointTs.recordDataPoint(mb.startTime, ts, val, changefeedIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudDbActiveConnectionsDataPoint adds a data point to tidb_cloud.db_active_connections metric.
func (mb *MetricsBuilder) RecordTidbCloudDbActiveConnectionsDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbActiveConnections.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbAverageQueryDurationDataPoint adds a data point to tidb_cloud.db_average_query_duration metric.
func (mb *MetricsBuilder) RecordTidbCloudDbAverageQueryDurationDataPoint(ts pcommon.Timestamp, val float64, sqlTypeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbAverageQueryDuration.recordDataPoint(mb.startTime, ts, val, sqlTypeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbColumnarStorageUsedBytesDataPoint adds a data point to tidb_cloud.db_columnar_storage_used_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudDbColumnarStorageUsedBytesDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudDbColumnarStorageUsedBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudDbCommandPerSecondDataPoint adds a data point to tidb_cloud.db_command_per_second metric.
func (mb *MetricsBuilder) RecordTidbCloudDbCommandPerSecondDataPoint(ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbCommandPerSecond.recordDataPoint(mb.startTime, ts, val, typeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbComponentUptimeDataPoint adds a data point to tidb_cloud.db_component_uptime metric.
func (mb *MetricsBuilder) RecordTidbCloudDbComponentUptimeDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbComponentUptime.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbConnectionsDataPoint adds a data point to tidb_cloud.db_connections metric.
func (mb *MetricsBuilder) RecordTidbCloudDbConnectionsDataPoint(ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, instanceAttributeValue string, clusterIDAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbConnections.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, instanceAttributeValue, clusterIDAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbDatabaseTimeDataPoint adds a data point to tidb_cloud.db_database_time metric.
func (mb *MetricsBuilder) RecordTidbCloudDbDatabaseTimeDataPoint(ts pcommon.Timestamp, val float64, sqlTypeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbDatabaseTime.recordDataPoint(mb.startTime, ts, val, sqlTypeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbDisconnectionsDataPoint adds a data point to tidb_cloud.db_disconnections metric.
func (mb *MetricsBuilder) RecordTidbCloudDbDisconnectionsDataPoint(ts pcommon.Timestamp, val float64, resultAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbDisconnections.recordDataPoint(mb.startTime, ts, val, resultAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbFailedQueriesDataPoint adds a data point to tidb_cloud.db_failed_queries metric.
func (mb *MetricsBuilder) RecordTidbCloudDbFailedQueriesDataPoint(ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbFailedQueries.recordDataPoint(mb.startTime, ts, val, typeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbFailedQueriesTotalDataPoint adds a data point to tidb_cloud.db_failed_queries_total metric.
func (mb *MetricsBuilder) RecordTidbCloudDbFailedQueriesTotalDataPoint(ts pcommon.Timestamp, val int64, typeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbFailedQueriesTotal.recordDataPoint(mb.startTime, ts, val, typeAttributeValue, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbKvRequestDurationDataPoint adds a data point to tidb_cloud.db_kv_request_duration metric.
func (mb *MetricsBuilder) RecordTidbCloudDbKvRequestDurationDataPoint(ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbKvRequestDuration.recordDataPoint(mb.startTime, ts, val, typeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbQueriesTotalDataPoint adds a data point to tidb_cloud.db_queries_total metric.
func (mb *MetricsBuilder) RecordTidbCloudDbQueriesTotalDataPoint(ts pcommon.Timestamp, val float64, sqlTypeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbQueriesTotal.recordDataPoint(mb.startTime, ts, val, sqlTypeAttributeValue, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbQueriesUsingPlanCacheOpsDataPoint adds a data point to tidb_cloud.db_queries_using_plan_cache_ops metric.
func (mb *MetricsBuilder) RecordTidbCloudDbQueriesUsingPlanCacheOpsDataPoint(ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbQueriesUsingPlanCacheOps.recordDataPoint(mb.startTime, ts, val, typeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbQueryDurationSecondsCountDataPoint adds a data point to tidb_cloud.db_query_duration_seconds.count metric.
func (mb *MetricsBuilder) RecordTidbCloudDbQueryDurationSecondsCountDataPoint(ts pcommon.Timestamp, val int64, sqlTypeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbQueryDurationSecondsCount.recordDataPoint(mb.startTime, ts, val, sqlTypeAttributeValue, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbQueryDurationSecondsSumDataPoint adds a data point to tidb_cloud.db_query_duration_seconds.sum metric.
func (mb *MetricsBuilder) RecordTidbCloudDbQueryDurationSecondsSumDataPoint(ts pcommon.Timestamp, val int64, sqlTypeAttributeValue string, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbQueryDurationSecondsSum.recordDataPoint(mb.startTime, ts, val, sqlTypeAttributeValue, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbQueryPerSecondDataPoint adds a data point to tidb_cloud.db_query_per_second metric.
func (mb *MetricsBuilder) RecordTidbCloudDbQueryPerSecondDataPoint(ts pcommon.Timestamp, val float64, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbQueryPerSecond.recordDataPoint(mb.startTime, ts, val, typeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbRowStorageUsedBytesDataPoint adds a data point to tidb_cloud.db_row_storage_used_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudDbRowStorageUsedBytesDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudDbRowStorageUsedBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudDbTotalConnectionDataPoint adds a data point to tidb_cloud.db_total_connection metric.
func (mb *MetricsBuilder) RecordTidbCloudDbTotalConnectionDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbTotalConnection.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDbTransactionPerSecondDataPoint adds a data point to tidb_cloud.db_transaction_per_second metric.
func (mb *MetricsBuilder) RecordTidbCloudDbTransactionPerSecondDataPoint(ts pcommon.Timestamp, val float64, txnModeAttributeValue string, typeAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudDbTransactionPerSecond.recordDataPoint(mb.startTime, ts, val, txnModeAttributeValue, typeAttributeValue, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudDmRelayReadErrorCountDataPoint adds a data point to tidb_cloud.dm_relay_read_error_count metric.
func (mb *MetricsBuilder) RecordTidbCloudDmRelayReadErrorCountDataPoint(ts pcommon.Timestamp, val float64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudDmRelayReadErrorCount.recordDataPoint(mb.startTime, ts, val, taskAttributeValue, jobIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudDmSyncerReplicationLagBucketDataPoint adds a data point to tidb_cloud.dm_syncer_replication_lag_bucket metric.
func (mb *MetricsBuilder) RecordTidbCloudDmSyncerReplicationLagBucketDataPoint(ts pcommon.Timestamp, val float64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudDmSyncerReplicationLagBucket.recordDataPoint(mb.startTime, ts, val, taskAttributeValue, jobIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudDmSyncerReplicationLagGaugeDataPoint adds a data point to tidb_cloud.dm_syncer_replication_lag_gauge metric.
func (mb *MetricsBuilder) RecordTidbCloudDmSyncerReplicationLagGaugeDataPoint(ts pcommon.Timestamp, val float64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudDmSyncerReplicationLagGauge.recordDataPoint(mb.startTime, ts, val, taskAttributeValue, jobIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudDmTaskStateDataPoint adds a data point to tidb_cloud.dm_task_state metric.
func (mb *MetricsBuilder) RecordTidbCloudDmTaskStateDataPoint(ts pcommon.Timestamp, val int64, taskAttributeValue string, jobIDAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudDmTaskState.recordDataPoint(mb.startTime, ts, val, taskAttributeValue, jobIDAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudNodeCPUCapacityCoresDataPoint adds a data point to tidb_cloud.node_cpu_capacity_cores metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeCPUCapacityCoresDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeCPUCapacityCores.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeCPUSecondsTotalDataPoint adds a data point to tidb_cloud.node_cpu_seconds_total metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeCPUSecondsTotalDataPoint(ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeCPUSecondsTotal.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeCPUSecondsTotalRateDataPoint adds a data point to tidb_cloud.node_cpu_seconds_total_rate metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeCPUSecondsTotalRateDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeCPUSecondsTotalRate.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeDiskReadLatencyDataPoint adds a data point to tidb_cloud.node_disk_read_latency metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeDiskReadLatencyDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string, deviceAttributeValue string) {
	mb.metricTidbCloudNodeDiskReadLatency.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue, deviceAttributeValue)
}

// RecordTidbCloudNodeDiskWriteLatencyDataPoint adds a data point to tidb_cloud.node_disk_write_latency metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeDiskWriteLatencyDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string, deviceAttributeValue string) {
	mb.metricTidbCloudNodeDiskWriteLatency.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue, deviceAttributeValue)
}

// RecordTidbCloudNodeMemoryAvailableBytesDataPoint adds a data point to tidb_cloud.node_memory_available_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeMemoryAvailableBytesDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeMemoryAvailableBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeMemoryCapacityBytesDataPoint adds a data point to tidb_cloud.node_memory_capacity_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeMemoryCapacityBytesDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeMemoryCapacityBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeMemoryUsedBytesDataPoint adds a data point to tidb_cloud.node_memory_used_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeMemoryUsedBytesDataPoint(ts pcommon.Timestamp, val float64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeMemoryUsedBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeStorageAvailableBytesDataPoint adds a data point to tidb_cloud.node_storage_available_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeStorageAvailableBytesDataPoint(ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeStorageAvailableBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeStorageCapacityBytesDataPoint adds a data point to tidb_cloud.node_storage_capacity_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeStorageCapacityBytesDataPoint(ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeStorageCapacityBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudNodeStorageUsedBytesDataPoint adds a data point to tidb_cloud.node_storage_used_bytes metric.
func (mb *MetricsBuilder) RecordTidbCloudNodeStorageUsedBytesDataPoint(ts pcommon.Timestamp, val int64, clusterNameAttributeValue string, clusterIDAttributeValue string, instanceAttributeValue string, componentAttributeValue AttributeComponent, projectNameAttributeValue string) {
	mb.metricTidbCloudNodeStorageUsedBytes.recordDataPoint(mb.startTime, ts, val, clusterNameAttributeValue, clusterIDAttributeValue, instanceAttributeValue, componentAttributeValue.String(), projectNameAttributeValue)
}

// RecordTidbCloudResourceManagerResourceUnitReadRequestUnitDataPoint adds a data point to tidb_cloud.resource_manager_resource_unit_read_request_unit metric.
func (mb *MetricsBuilder) RecordTidbCloudResourceManagerResourceUnitReadRequestUnitDataPoint(ts pcommon.Timestamp, val float64, resourceGroupAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudResourceManagerResourceUnitReadRequestUnit.recordDataPoint(mb.startTime, ts, val, resourceGroupAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudResourceManagerResourceRequestUnitTotalDataPoint adds a data point to tidb_cloud.resource_manager_resource_request_unit_total metric.
func (mb *MetricsBuilder) RecordTidbCloudResourceManagerResourceRequestUnitTotalDataPoint(ts pcommon.Timestamp, val float64, resourceGroupAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudResourceManagerResourceRequestUnitTotal.recordDataPoint(mb.startTime, ts, val, resourceGroupAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// RecordTidbCloudResourceManagerResourceUnitWriteRequestUnitDataPoint adds a data point to tidb_cloud.resource_manager_resource_unit_write_request_unit metric.
func (mb *MetricsBuilder) RecordTidbCloudResourceManagerResourceUnitWriteRequestUnitDataPoint(ts pcommon.Timestamp, val float64, resourceGroupAttributeValue string, clusterNameAttributeValue string, instanceAttributeValue string, projectNameAttributeValue string) {
	mb.metricTidbCloudResourceManagerResourceUnitWriteRequestUnit.recordDataPoint(mb.startTime, ts, val, resourceGroupAttributeValue, clusterNameAttributeValue, instanceAttributeValue, projectNameAttributeValue)
}

// Reset resets metrics builder to its initial state. It should be used when external metrics source is restarted,
// and metrics builder should update its startTime and reset it's internal state accordingly.
func (mb *MetricsBuilder) Reset(options ...MetricBuilderOption) {
	mb.startTime = pcommon.NewTimestampFromTime(time.Now())
	for _, op := range options {
		op.apply(mb)
	}
}
