-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(metrics): add metrics to udf (#14090)
Signed-off-by: Runji Wang <wangrunji0408@163.com>
- v2.1.0
- v2.1.0-rc.2
- v2.1.0-rc.1
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0-rc.1
- v2.0.0-jw-test
- v1.10.2
- v1.10.1
- v1.10.0
- v1.10.0-rc.3
- v1.10.0-rc.2
- v1.10.0-rc.1
- v1.9.2
- v1.9.1
- v1.9.1-rc.2
- v1.9.1-rc.1
- v1.9.0
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.7.0-standalone
- v1.7.0-single-node-2
- v1.7.0-single-node
- v1.6.1
- v1.6.0
1 parent
09b3c3c
commit 95466f5
Showing
9 changed files
with
263 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2023 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use std::sync::LazyLock; | ||
|
||
use prometheus::{ | ||
exponential_buckets, register_histogram_vec_with_registry, | ||
register_int_counter_vec_with_registry, HistogramVec, IntCounterVec, Registry, | ||
}; | ||
use risingwave_common::monitor::GLOBAL_METRICS_REGISTRY; | ||
|
||
/// Monitor metrics for UDF. | ||
#[derive(Debug, Clone)] | ||
pub struct Metrics { | ||
/// Number of successful UDF calls. | ||
pub udf_success_count: IntCounterVec, | ||
/// Number of failed UDF calls. | ||
pub udf_failure_count: IntCounterVec, | ||
/// Input chunk rows of UDF calls. | ||
pub udf_input_chunk_rows: HistogramVec, | ||
/// The latency of UDF calls in seconds. | ||
pub udf_latency: HistogramVec, | ||
/// Total number of input rows of UDF calls. | ||
pub udf_input_rows: IntCounterVec, | ||
/// Total number of input bytes of UDF calls. | ||
pub udf_input_bytes: IntCounterVec, | ||
} | ||
|
||
/// Global UDF metrics. | ||
pub static GLOBAL_METRICS: LazyLock<Metrics> = | ||
LazyLock::new(|| Metrics::new(&GLOBAL_METRICS_REGISTRY)); | ||
|
||
impl Metrics { | ||
fn new(registry: &Registry) -> Self { | ||
let labels = &["link", "name"]; | ||
let udf_success_count = register_int_counter_vec_with_registry!( | ||
"udf_success_count", | ||
"Total number of successful UDF calls", | ||
labels, | ||
registry | ||
) | ||
.unwrap(); | ||
let udf_failure_count = register_int_counter_vec_with_registry!( | ||
"udf_failure_count", | ||
"Total number of failed UDF calls", | ||
labels, | ||
registry | ||
) | ||
.unwrap(); | ||
let udf_input_chunk_rows = register_histogram_vec_with_registry!( | ||
"udf_input_chunk_rows", | ||
"Input chunk rows of UDF calls", | ||
labels, | ||
exponential_buckets(1.0, 2.0, 10).unwrap(), // 1 to 1024 | ||
registry | ||
) | ||
.unwrap(); | ||
let udf_latency = register_histogram_vec_with_registry!( | ||
"udf_latency", | ||
"The latency(s) of UDF calls", | ||
labels, | ||
exponential_buckets(0.000001, 2.0, 30).unwrap(), // 1us to 1000s | ||
registry | ||
) | ||
.unwrap(); | ||
let udf_input_rows = register_int_counter_vec_with_registry!( | ||
"udf_input_rows", | ||
"Total number of input rows of UDF calls", | ||
labels, | ||
registry | ||
) | ||
.unwrap(); | ||
let udf_input_bytes = register_int_counter_vec_with_registry!( | ||
"udf_input_bytes", | ||
"Total number of input bytes of UDF calls", | ||
labels, | ||
registry | ||
) | ||
.unwrap(); | ||
|
||
Metrics { | ||
udf_success_count, | ||
udf_failure_count, | ||
udf_input_chunk_rows, | ||
udf_latency, | ||
udf_input_rows, | ||
udf_input_bytes, | ||
} | ||
} | ||
} |