-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api] Add metrics to api tester (#9307)
This commit introduces logging tools on top of the consistent API testing introduced here. See proposal for more high level information. Changes: Added metrics pusher to aptos-api-tester with 4 histogram metrics for success, error, fail rates, and latency. Added logs to tests instead of printing to stdout.
- Loading branch information
Showing
5 changed files
with
260 additions
and
47 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.
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,55 @@ | ||
// Copyright © Aptos Foundation | ||
|
||
use once_cell::sync::Lazy; | ||
use prometheus::{register_histogram_vec, Histogram, HistogramVec}; | ||
|
||
pub static API_TEST_SUCCESS: Lazy<HistogramVec> = Lazy::new(|| { | ||
register_histogram_vec!( | ||
"api_test_success", | ||
"Number of user flows which succesfully passed", | ||
&["test_name", "network_name"], | ||
) | ||
.unwrap() | ||
}); | ||
|
||
pub fn test_success(test_name: &str, network_name: &str) -> Histogram { | ||
API_TEST_SUCCESS.with_label_values(&[test_name, network_name]) | ||
} | ||
|
||
pub static API_TEST_FAIL: Lazy<HistogramVec> = Lazy::new(|| { | ||
register_histogram_vec!( | ||
"api_test_fail", | ||
"Number of user flows which failed checks", | ||
&["test_name", "network_name"], | ||
) | ||
.unwrap() | ||
}); | ||
|
||
pub fn test_fail(test_name: &str, network_name: &str) -> Histogram { | ||
API_TEST_FAIL.with_label_values(&[test_name, network_name]) | ||
} | ||
|
||
pub static API_TEST_ERROR: Lazy<HistogramVec> = Lazy::new(|| { | ||
register_histogram_vec!("api_test_error", "Number of user flows which crashed", &[ | ||
"test_name", | ||
"network_name", | ||
]) | ||
.unwrap() | ||
}); | ||
|
||
pub fn test_error(test_name: &str, network_name: &str) -> Histogram { | ||
API_TEST_ERROR.with_label_values(&[test_name, network_name]) | ||
} | ||
|
||
pub static API_TEST_LATENCY: Lazy<HistogramVec> = Lazy::new(|| { | ||
register_histogram_vec!( | ||
"api_test_latency", | ||
"Time it takes to complete a user flow", | ||
&["test_name", "network_name", "result"], | ||
) | ||
.unwrap() | ||
}); | ||
|
||
pub fn test_latency(test_name: &str, network_name: &str, result: &str) -> Histogram { | ||
API_TEST_LATENCY.with_label_values(&[test_name, network_name, result]) | ||
} |
Oops, something went wrong.