operator/
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
18lazy_static! {
19    pub static ref DIST_CREATE_TABLE: Histogram = register_histogram!(
20        "greptime_table_operator_create_table",
21        "table operator create table"
22    )
23    .unwrap();
24    pub static ref DIST_CREATE_TABLES: Histogram = register_histogram!(
25        "greptime_table_operator_create_tables",
26        "table operator create table"
27    )
28    .unwrap();
29    pub static ref DIST_ALTER_TABLES: Histogram = register_histogram!(
30        "greptime_table_operator_alter_tables",
31        "table operator alter table"
32    )
33    .unwrap();
34    pub static ref DIST_INGEST_ROW_COUNT: IntCounter = register_int_counter!(
35        "greptime_table_operator_ingest_rows",
36        "table operator ingest rows"
37    )
38    .unwrap();
39    pub static ref DIST_MIRROR_ROW_COUNT: IntCounter = register_int_counter!(
40        "greptime_table_operator_mirror_rows",
41        "table operator mirror rows"
42    )
43    .unwrap();
44    pub static ref DIST_MIRROR_PENDING_ROW_COUNT: IntGauge = register_int_gauge!(
45        "greptime_table_operator_mirror_pending_rows",
46        "table operator mirror pending rows"
47    )
48    .unwrap();
49    pub static ref DIST_DELETE_ROW_COUNT: IntCounter = register_int_counter!(
50        "greptime_table_operator_delete_rows",
51        "table operator delete rows"
52    )
53    .unwrap();
54    pub static ref DIST_CREATE_VIEW: Histogram = register_histogram!(
55        "greptime_ddl_operator_create_view",
56        "DDL operator create view"
57    )
58    .unwrap();
59    pub static ref CREATE_ALTER_ON_DEMAND: HistogramVec = register_histogram_vec!(
60        "greptime_table_operator_create_alter_on_demand",
61        "table operator duration to create or alter tables on demand",
62        &["table_type"]
63    )
64    .unwrap();
65    pub static ref HANDLE_BULK_INSERT_ELAPSED: HistogramVec = register_histogram_vec!(
66        "greptime_table_operator_handle_bulk_insert",
67        "table operator duration to handle bulk inserts",
68        &["stage"],
69        vec![
70            0.001, 0.005, 0.01, 0.02, 0.03, 0.04, 0.05, 0.10, 0.15, 0.2, 0.3, 0.4, 0.5, 1.0, 1.5,
71            2.0, 2.5, 3.0, 4.0, 5.0
72        ]
73    )
74    .unwrap();
75    pub static ref BULK_REQUEST_MESSAGE_SIZE: Histogram = register_histogram!(
76        "greptime_table_operator_bulk_insert_message_size",
77        "table operator bulk inserts message encoded size",
78        vec![
79            32768.0,
80            65536.0,
81            131072.0,
82            262144.0,
83            524288.0,
84            1048576.0,
85            2097152.0,
86            4194304.0,
87            8388608.0,
88            16777216.0,
89            33554432.0,
90            67108864.0,
91            134217728.0,
92            268435456.0
93        ]
94    )
95    .unwrap();
96    pub static ref BULK_REQUEST_ROWS: HistogramVec = register_histogram_vec!(
97        "greptime_table_operator_bulk_insert_message_rows",
98        "table operator bulk inserts message rows",
99        &["type"],
100        // 10 ~ 100_000
101        exponential_buckets(10.0, 10.0, 5).unwrap()
102    )
103    .unwrap();
104}