forked from pingcap/tidb-engine-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics.rs
59 lines (55 loc) · 2.31 KB
/
metrics.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2023 TiKV Project Authors. Licensed under Apache-2.0.
use lazy_static::*;
use prometheus::*;
lazy_static! {
pub static ref BACKGROUND_QUOTA_LIMIT_VEC: IntGaugeVec = register_int_gauge_vec!(
"tikv_resource_control_background_quota_limiter",
"The quota limiter of background resource groups per resource type",
&["resource_group", "type"]
)
.unwrap();
pub static ref BACKGROUND_RESOURCE_CONSUMPTION: IntCounterVec = register_int_counter_vec!(
"tikv_resource_control_background_resource_consumption",
"Total resource consumed of background resource groups per resource type",
&["resource_group", "type"]
)
.unwrap();
pub static ref BACKGROUND_TASKS_WAIT_DURATION: IntCounterVec = register_int_counter_vec!(
"tikv_resource_control_background_task_wait_duration",
"Total wait duration of background tasks per resource group",
&["resource_group"]
)
.unwrap();
pub static ref PRIORITY_QUOTA_LIMIT_VEC: IntGaugeVec = register_int_gauge_vec!(
"tikv_resource_control_priority_quota_limit",
"The quota limiter for each priority in resource control",
&["priority"]
)
.unwrap();
pub static ref PRIORITY_CPU_TIME_VEC: IntCounterVec = register_int_counter_vec!(
"tikv_resource_control_priority_task_exec_duration",
"Total execution duration of tasks per-priority",
&["priority"]
)
.unwrap();
pub static ref PRIORITY_WAIT_DURATION_VEC: HistogramVec = register_histogram_vec!(
"tikv_resource_control_priority_wait_duration",
"Histogram of wait duration cause by priority quota limiter",
&["priority"],
exponential_buckets(1e-5, 2.0, 22).unwrap() // 10us ~ 42s
)
.unwrap();
pub static ref BACKGROUND_TASK_RESOURCE_UTILIZATION_VEC: IntGaugeVec = register_int_gauge_vec!(
"tikv_resource_control_bg_resource_utilization",
"The total resource utilization percentage of background tasks",
&["type"]
)
.unwrap();
}
pub fn deregister_metrics(name: &str) {
for ty in ["cpu", "io"] {
_ = BACKGROUND_QUOTA_LIMIT_VEC.remove_label_values(&[name, ty]);
_ = BACKGROUND_RESOURCE_CONSUMPTION.remove_label_values(&[name, ty]);
}
_ = BACKGROUND_TASKS_WAIT_DURATION.remove_label_values(&[name]);
}