Skip to main content

servers/batcher/table/
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    Histogram, IntCounter, IntGauge, register_histogram, register_int_counter, register_int_gauge,
18};
19
20lazy_static! {
21    pub(in crate::batcher::table) static ref PENDING_WORKERS: IntGauge = register_int_gauge!(
22        "greptime_table_batcher_pending_workers",
23        "Registered table batch workers"
24    )
25    .unwrap();
26    pub(in crate::batcher::table) static ref FLUSH_DROPPED_ROWS: IntCounter =
27        register_int_counter!(
28            "greptime_table_batcher_flush_dropped_rows",
29            "Rows in failed table batch flushes"
30        )
31        .unwrap();
32    pub(in crate::batcher::table) static ref PENDING_BATCHES: IntGauge = register_int_gauge!(
33        "greptime_table_batcher_pending_batches",
34        "Pending table batches"
35    )
36    .unwrap();
37    pub(in crate::batcher::table) static ref PENDING_ROWS: IntGauge = register_int_gauge!(
38        "greptime_table_batcher_pending_rows",
39        "Rows awaiting table batch flush"
40    )
41    .unwrap();
42    pub(in crate::batcher::table) static ref FLUSH_TOTAL: IntCounter = register_int_counter!(
43        "greptime_table_batcher_flush_total",
44        "Successful table batch flushes"
45    )
46    .unwrap();
47    pub(in crate::batcher::table) static ref FLUSH_FAILURES: IntCounter = register_int_counter!(
48        "greptime_table_batcher_flush_failures",
49        "Failed table batch flushes"
50    )
51    .unwrap();
52    pub(in crate::batcher::table) static ref FLUSH_ROWS: Histogram = register_histogram!(
53        "greptime_table_batcher_flush_rows",
54        "Number of rows per successful table batch flush",
55        vec![100.0, 1000.0, 10000.0, 50000.0, 100000.0, 500000.0]
56    )
57    .unwrap();
58    pub(in crate::batcher::table) static ref FLUSH_ELAPSED: Histogram = register_histogram!(
59        "greptime_table_batcher_flush_elapsed",
60        "Table batch flush duration in seconds",
61        vec![0.005, 0.01, 0.05, 0.1, 0.5, 1.0, 5.0, 10.0, 60.0, 300.0]
62    )
63    .unwrap();
64}