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: IntCounterVec = register_int_counter_vec!(
35        "greptime_table_operator_ingest_rows",
36        "table operator ingest rows",
37        &["db"]
38    )
39    .unwrap();
40    pub static ref DIST_MIRROR_ROW_COUNT: IntCounter = register_int_counter!(
41        "greptime_table_operator_mirror_rows",
42        "table operator mirror rows"
43    )
44    .unwrap();
45    pub static ref DIST_MIRROR_PENDING_ROW_COUNT: IntGauge = register_int_gauge!(
46        "greptime_table_operator_mirror_pending_rows",
47        "table operator mirror pending rows"
48    )
49    .unwrap();
50    pub static ref DIST_DELETE_ROW_COUNT: IntCounterVec = register_int_counter_vec!(
51        "greptime_table_operator_delete_rows",
52        "table operator delete rows",
53        &["db"]
54    )
55    .unwrap();
56    pub static ref DIST_CREATE_VIEW: Histogram = register_histogram!(
57        "greptime_ddl_operator_create_view",
58        "DDL operator create view"
59    )
60    .unwrap();
61    pub static ref CREATE_ALTER_ON_DEMAND: HistogramVec = register_histogram_vec!(
62        "greptime_table_operator_create_alter_on_demand",
63        "table operator duration to create or alter tables on demand",
64        &["table_type"]
65    )
66    .unwrap();
67    pub static ref HANDLE_BULK_INSERT_ELAPSED: HistogramVec = register_histogram_vec!(
68        "greptime_table_operator_handle_bulk_insert",
69        "table operator duration to handle bulk inserts",
70        &["stage"],
71        vec![
72            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,
73            2.0, 2.5, 3.0, 4.0, 5.0
74        ]
75    )
76    .unwrap();
77    pub static ref BULK_REQUEST_MESSAGE_SIZE: Histogram = register_histogram!(
78        "greptime_table_operator_bulk_insert_message_size",
79        "table operator bulk inserts message encoded size",
80        vec![
81            32768.0,
82            65536.0,
83            131072.0,
84            262144.0,
85            524288.0,
86            1048576.0,
87            2097152.0,
88            4194304.0,
89            8388608.0,
90            16777216.0,
91            33554432.0,
92            67108864.0,
93            134217728.0,
94            268435456.0
95        ]
96    )
97    .unwrap();
98    pub static ref BULK_REQUEST_ROWS: HistogramVec = register_histogram_vec!(
99        "greptime_table_operator_bulk_insert_message_rows",
100        "table operator bulk inserts message rows",
101        &["type"],
102        // 10 ~ 100_000
103        exponential_buckets(10.0, 10.0, 5).unwrap()
104    )
105    .unwrap();
106}