Skip to main content

common_meta/
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
15use lazy_static::lazy_static;
16use prometheus::*;
17
18pub const TABLE_TYPE_PHYSICAL: &str = "physical";
19pub const TABLE_TYPE_LOGICAL: &str = "logical";
20pub const ERROR_TYPE_RETRYABLE: &str = "retryable";
21pub const ERROR_TYPE_EXTERNAL: &str = "external";
22pub const STATS_TYPE_NO_REGION_METADATA: &str = "no_region_metadata";
23pub const STATS_TYPE_REGION_NOT_OPEN: &str = "region_not_open";
24
25lazy_static! {
26    pub static ref METRIC_AUTHORITY_STORAGE_EVENTS: IntCounterVec = register_int_counter_vec!(
27        "greptime_meta_authority_storage_events", "Authority storage failures and conflicts", &["outcome"]
28    ).unwrap();
29    pub static ref METRIC_META_TXN_REQUEST: HistogramVec = register_histogram_vec!(
30        "greptime_meta_txn_request",
31        "meta txn request",
32        &["target", "op"]
33    )
34    .unwrap();
35    pub static ref METRIC_META_CREATE_CATALOG: Histogram =
36        register_histogram!("greptime_meta_create_catalog", "meta create catalog").unwrap();
37    pub static ref METRIC_META_CREATE_CATALOG_COUNTER: IntCounter = register_int_counter!(
38        "greptime_meta_create_catalog_counter",
39        "meta create catalog"
40    )
41    .unwrap();
42    pub static ref METRIC_META_CREATE_SCHEMA: Histogram =
43        register_histogram!("greptime_meta_create_schema", "meta create schema").unwrap();
44    pub static ref METRIC_META_CREATE_SCHEMA_COUNTER: IntCounter =
45        register_int_counter!("greptime_meta_create_schema_counter", "meta create schema").unwrap();
46    pub static ref METRIC_META_PROCEDURE_CREATE_TABLE: HistogramVec = register_histogram_vec!(
47        "greptime_meta_procedure_create_table",
48        "meta procedure create table",
49        &["step"]
50    )
51    .unwrap();
52    pub static ref METRIC_META_PROCEDURE_CREATE_VIEW: HistogramVec = register_histogram_vec!(
53        "greptime_meta_procedure_create_view",
54        "meta procedure create view",
55        &["step"]
56    )
57    .unwrap();
58    pub static ref METRIC_META_PROCEDURE_CREATE_FLOW: HistogramVec = register_histogram_vec!(
59        "greptime_meta_procedure_create_flow",
60        "meta procedure create flow",
61        &["step"]
62    )
63    .unwrap();
64    pub static ref METRIC_META_PROCEDURE_DROP_FLOW: HistogramVec = register_histogram_vec!(
65        "greptime_meta_procedure_drop_flow",
66        "meta procedure drop flow",
67        &["step"]
68    )
69        .unwrap();
70    pub static ref METRIC_META_PROCEDURE_DROP_VIEW: HistogramVec = register_histogram_vec!(
71        "greptime_meta_procedure_drop_view",
72        "meta procedure drop view",
73        &["step"]
74    )
75    .unwrap();
76    pub static ref METRIC_META_PROCEDURE_CREATE_TABLES: HistogramVec = register_histogram_vec!(
77        "greptime_meta_procedure_create_tables",
78        "meta procedure create tables",
79        &["step"]
80    )
81    .unwrap();
82    pub static ref METRIC_META_PROCEDURE_DROP_TABLE: HistogramVec = register_histogram_vec!(
83        "greptime_meta_procedure_drop_table",
84        "meta procedure drop table",
85        &["step"]
86    )
87    .unwrap();
88    pub static ref METRIC_META_PROCEDURE_ALTER_TABLE: HistogramVec = register_histogram_vec!(
89        "greptime_meta_procedure_alter_table",
90        "meta procedure alter table",
91        &["step"]
92    )
93    .unwrap();
94    pub static ref METRIC_META_PROCEDURE_TRUNCATE_TABLE: HistogramVec = register_histogram_vec!(
95        "greptime_meta_procedure_truncate_table",
96        "meta procedure truncate table",
97        &["step"]
98    )
99    .unwrap();
100    /// Cache container cache get counter.
101    pub static ref CACHE_CONTAINER_CACHE_GET: IntCounterVec = register_int_counter_vec!(
102        "greptime_meta_cache_container_cache_get",
103        "cache container cache get",
104        &["name"]
105    )
106    .unwrap();
107    /// Cache container cache miss counter.
108    pub static ref CACHE_CONTAINER_CACHE_MISS: IntCounterVec = register_int_counter_vec!(
109        "greptime_meta_cache_container_cache_miss",
110        "cache container cache miss",
111        &["name"]
112    )
113    .unwrap();
114    /// Cache container load cache timer
115    pub static ref CACHE_CONTAINER_LOAD_CACHE: HistogramVec = register_histogram_vec!(
116        "greptime_meta_cache_container_load_cache",
117        "cache container load cache",
118        &["name"]
119    )
120    .unwrap();
121    pub static ref RDS_SQL_EXECUTE_ELAPSED: HistogramVec = register_histogram_vec!(
122        "greptime_meta_rds_pg_sql_execute_elapsed_ms",
123        "rds pg sql execute elapsed",
124        &["backend", "result", "op", "type"]
125    )
126    .unwrap();
127    pub static ref METRIC_META_RECONCILIATION_LIST_REGION_METADATA_DURATION: HistogramVec =
128        register_histogram_vec!(
129            "greptime_meta_reconciliation_list_region_metadata_duration",
130            "reconciliation list region metadata duration",
131            &["table_type"]
132        )
133        .unwrap();
134    pub static ref METRIC_META_RECONCILIATION_RESOLVED_COLUMN_METADATA: IntCounterVec =
135        register_int_counter_vec!(
136            "greptime_meta_reconciliation_resolved_column_metadata",
137            "reconciliation resolved column metadata",
138            &["strategy"]
139        )
140        .unwrap();
141    pub static ref METRIC_META_RECONCILIATION_STATS: IntCounterVec =
142        register_int_counter_vec!(
143            "greptime_meta_reconciliation_stats",
144            "reconciliation stats",
145            &["procedure_name", "table_type", "type"]
146        )
147        .unwrap();
148    pub static ref METRIC_META_RECONCILIATION_PROCEDURE: HistogramVec =
149        register_histogram_vec!(
150            "greptime_meta_reconciliation_procedure",
151            "reconcile table procedure",
152            &["procedure_name", "step"]
153        )
154        .unwrap();
155    pub static ref METRIC_META_RECONCILIATION_PROCEDURE_ERROR: IntCounterVec =
156        register_int_counter_vec!(
157            "greptime_meta_reconciliation_procedure_error",
158            "reconciliation procedure error",
159            &["procedure_name", "step", "error_type"]
160        )
161        .unwrap();
162}