Skip to content

Commit 3547bee

Browse files
authored
fix(metrics): remove high cardinality labels in metrics (#17820)
* remove metrics on table locks acq/created with high cardinality table_id * remove root label in opendal metrics
1 parent 407e425 commit 3547bee

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/common/metrics/src/metrics/lock.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ static SHUTDOWN_LOCK_HOLDER_NUMS: LazyLock<Counter> =
3838
const LABEL_TYPE: &str = "type";
3939
const LABEL_TABLE_ID: &str = "table_id";
4040

41-
pub fn record_created_lock_nums(lock_type: String, table_id: u64, num: u64) {
42-
let labels = &vec![
43-
(LABEL_TYPE, lock_type),
44-
(LABEL_TABLE_ID, table_id.to_string()),
45-
];
41+
pub fn record_created_lock_nums(lock_type: String, num: u64) {
42+
let labels = &vec![(LABEL_TYPE, lock_type)];
4643
CREATED_LOCK_NUMS.get_or_create(labels).inc_by(num);
4744
}
4845

49-
pub fn record_acquired_lock_nums(lock_type: String, table_id: u64, num: u64) {
50-
let labels = &vec![
51-
(LABEL_TYPE, lock_type),
52-
(LABEL_TABLE_ID, table_id.to_string()),
53-
];
46+
pub fn record_acquired_lock_nums(lock_type: String, num: u64) {
47+
let labels = &vec![(LABEL_TYPE, lock_type)];
5448
ACQUIRED_LOCK_NUMS.get_or_create(labels).inc_by(num);
5549
}
5650

src/common/storage/src/metrics_layer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ impl EncodeLabelSet for OperationLabels {
242242
fn encode(&self, mut encoder: LabelSetEncoder) -> Result<(), fmt::Error> {
243243
(observe::LABEL_SCHEME, self.0.scheme.into_static()).encode(encoder.encode_label())?;
244244
(observe::LABEL_NAMESPACE, self.0.namespace.as_ref()).encode(encoder.encode_label())?;
245-
(observe::LABEL_ROOT, self.0.root.as_ref()).encode(encoder.encode_label())?;
246245
(observe::LABEL_OPERATION, self.0.operation).encode(encoder.encode_label())?;
247246

248247
if let Some(error) = &self.0.error {

src/query/service/src/locks/lock_holder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl LockHolder {
103103

104104
catalog.extend_lock_revision(extend_table_lock_req).await?;
105105
// metrics.
106-
record_acquired_lock_nums(lock_type, table_id, 1);
106+
record_acquired_lock_nums(lock_type, 1);
107107
break;
108108
}
109109

@@ -174,7 +174,7 @@ impl LockHolder {
174174
let res = catalog.create_lock_revision(req).await?;
175175
let revision = res.revision;
176176
// metrics.
177-
record_created_lock_nums(lock_key.lock_type().to_string(), lock_key.get_table_id(), 1);
177+
record_created_lock_nums(lock_key.lock_type().to_string(), 1);
178178
log::debug!("create table lock success, revision={}", revision);
179179

180180
let delete_table_lock_req = DeleteLockRevReq::new(lock_key.clone(), revision);

0 commit comments

Comments
 (0)