metric_engine/
metrics.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Internal metrics for observability.
16
17use lazy_static::lazy_static;
18use prometheus::*;
19
20/// Stage label.
21pub const OPERATION_LABEL: &str = "operation";
22
23lazy_static! {
24    /// Gauge for opened regions
25    pub static ref PHYSICAL_REGION_COUNT: IntGauge =
26        register_int_gauge!("greptime_metric_engine_physical_region_count", "metric engine physical region count").unwrap();
27
28    /// Gauge of columns across all opened regions
29    pub static ref PHYSICAL_COLUMN_COUNT: IntGauge =
30        register_int_gauge!("greptime_metric_engine_physical_column_count", "metric engine physical column count").unwrap();
31
32    /// Gauge for opened logical regions
33    pub static ref LOGICAL_REGION_COUNT: IntGauge =
34        register_int_gauge!("greptime_metric_engine_logical_region_count", "metric engine logical region count").unwrap();
35
36    /// Histogram for opened logical regions
37    pub static ref MITO_DDL_DURATION: Histogram =
38        register_histogram!("greptime_metric_engine_mito_ddl", "metric engine mito ddl").unwrap();
39
40    /// Counter for forbidden operations
41    pub static ref FORBIDDEN_OPERATION_COUNT: IntCounter =
42        register_int_counter!("greptime_metric_engine_forbidden_request", "metric forbidden request").unwrap();
43
44    /// Histogram for underlying mito operations
45    pub static ref MITO_OPERATION_ELAPSED: HistogramVec = register_histogram_vec!(
46        "greptime_metric_engine_mito_op_elapsed",
47        "metric engine's mito operation elapsed",
48        &[OPERATION_LABEL],
49        // 0.01 ~ 10000
50        exponential_buckets(0.01, 10.0, 7).unwrap(),
51    )
52    .unwrap();
53}