Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r2r] update metrics related dep && refactoring #1312

Merged
merged 49 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fe04dfd
update metrics related dep
borngraced Jun 15, 2022
6dde2f0
wasm don't mess up!
borngraced Jun 15, 2022
39fac2a
wip
borngraced Jun 17, 2022
dad1905
wip
borngraced Jun 17, 2022
81f0838
impl collect_json done
borngraced Jun 19, 2022
0143dac
added collect_json test
borngraced Jun 19, 2022
4aeeaa9
created new mm2_metrics crate and other wip impls
borngraced Jun 21, 2022
526cee4
update wasm
borngraced Jun 21, 2022
75a545a
rust fmt check
borngraced Jun 21, 2022
06df12e
wip
borngraced Jun 22, 2022
2fda9cd
MetricsArc && MetricsWeak
borngraced Jun 22, 2022
942e5b9
wip
borngraced Jun 24, 2022
3c274aa
wip
borngraced Jun 26, 2022
ae7829f
removed unused dep
borngraced Jun 26, 2022
a0f5908
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
borngraced Jun 29, 2022
a86bef9
refactoring
borngraced Jun 29, 2022
23af3b8
removed unused deps
borngraced Jun 29, 2022
d540ad1
collect gauge from bits to u64
borngraced Jun 29, 2022
4a0a05d
gauge now export u64
borngraced Jun 29, 2022
d277088
updated histogram and gauge
borngraced Jun 29, 2022
584b91c
iteration
borngraced Jun 30, 2022
3b1637d
reiteration
borngraced Jul 3, 2022
8a75994
reiteration
borngraced Jul 3, 2022
3ebb526
Iterations
borngraced Jul 7, 2022
8da9de6
histogram, label macro and other improvements
borngraced Jul 7, 2022
237c40e
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
borngraced Jul 11, 2022
7228d1d
fixed conflicts
borngraced Jul 11, 2022
64b1b7c
fix udeps, impl wasm for metrics and other iterations
borngraced Jul 11, 2022
54dc712
code improvements
borngraced Jul 18, 2022
e433a83
improved TryRecorder for MetricsWeak
borngraced Jul 25, 2022
d505d50
renamed native to mm_metrics
borngraced Jul 26, 2022
26e1fb9
fix cargo fmt
borngraced Jul 26, 2022
51fa8f7
changed incompatible quanta dep --v
borngraced Jul 26, 2022
83621b6
PR review fixes - 1
borngraced Jul 27, 2022
569871f
PR Review fixes -2
borngraced Jul 27, 2022
482babd
Fix WASM
borngraced Jul 27, 2022
13c53a3
PR review fixes - wip
borngraced Jul 28, 2022
12b8a1c
PR review fixes
borngraced Jul 28, 2022
3ec0d88
Changes to error handling and unit tests
borngraced Jul 29, 2022
7cf9cc0
Fixed test_collect_json test deltas
borngraced Jul 29, 2022
63b5713
PR review fixes - 3
borngraced Aug 1, 2022
f81d62e
edited lp_commands_legacy
borngraced Aug 1, 2022
4e813bb
PR review fix - last
borngraced Aug 1, 2022
c9544ff
Minor changes - r2r
borngraced Aug 4, 2022
8a2e021
fix cargo clippy
borngraced Aug 4, 2022
decaae2
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
borngraced Aug 4, 2022
914cfd0
final pr review changes
borngraced Aug 5, 2022
9d16b20
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
borngraced Aug 5, 2022
5797bc4
fixed build error
borngraced Aug 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mm2src/mm2_metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum MmMetricsError {
PrometheusAuthorizationRequired,
#[display(fmt = "Warning Prometheus: invalid credentials: {}", _0)]
PrometheusInvalidCredentials(String),
#[display(fmt = "Prometheus Server Error: {}", _0)]
PrometheusServerError(String),
#[display(fmt = "Warning Prometheus: unexpected URI {}", _0)]
UnexpectedUri(String),
}
Expand Down
64 changes: 30 additions & 34 deletions mm2src/mm2_metrics/src/mm_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ pub mod prometheus {
});

let server = Server::try_bind(&address)
.map_err(|e| MmMetricsError::Internal(e.to_string()))?
.map_err(|e| MmMetricsError::PrometheusServerError(e.to_string()))?
.http1_half_close(false) // https://github.com/hyperium/hyper/issues/1764
.serve(make_svc)
.with_graceful_shutdown(shutdown_detector);
Expand Down Expand Up @@ -397,7 +397,7 @@ mod test {
mm_gauge!(metrics, "rpc.connection.count", 3.0, "coin" => "KMD");
mm_gauge!(metrics, "rpc.connection.count", 5.0, "coin" => "KMD");

let delta = Duration::from_secs(1);
let delta = Duration::from_secs(2);
mm_timing!(metrics,
"rpc.query.spent_time",
// ~ 1 second
Expand Down Expand Up @@ -442,8 +442,8 @@ mod test {
"count": 2.0,
"key": "rpc.query.spent_time",
"labels": { "coin": "KMD", "method": "blockchain.transaction.get" },
"max": 1.0,
"min": 1.0,
"max": 2.0,
"min": 2.0,
sergeyboyko0791 marked this conversation as resolved.
Show resolved Hide resolved
"type": "histogram"
},
{
Expand Down Expand Up @@ -522,34 +522,30 @@ mod test {
block_on(async { Timer::sleep(6.).await });
}

// #[test]
// fn test_prometheus_format() {
// let mm_metrics = MetricsArc::new();
//
// mm_metrics.init();
//
// mm_counter!(mm_metrics, "rpc.traffic.tx", 62, "coin" => "BTC");
// mm_counter!(mm_metrics, "rpc.traffic.rx", 105, "coin" => "BTC");
//
// mm_counter!(mm_metrics, "rpc.traffic.tx", 30, "coin" => "BTC");
// mm_counter!(mm_metrics, "rpc.traffic.rx", 44, "coin" => "BTC");
//
// mm_counter!(mm_metrics, "rpc.traffic.tx", 54, "coin" => "KMD");
// mm_counter!(mm_metrics, "rpc.traffic.rx", 158, "coin" => "KMD");
//
// mm_gauge!(mm_metrics, "rpc.connection.count", 3.0, "coin" => "KMD");
// mm_gauge!(mm_metrics, "rpc.connection.count", 5.0, "coin" => "KMD");
//
// mm_timing!(mm_metrics,
// "rpc.query.spent_time",
// 4.5,
// "coin"=> "KMD",
// "method"=>"blockchain.transaction.get");
//
// let actual = mm_metrics.0.collect_prometheus_format();
// let expected = concat!("# TYPE rpc_traffic_tx counter\nrpc_traffic_tx{coin=\"BTC\"} \
// 92\nrpc_traffic_tx{coin=\"KMD\"} 54\n\n# TYPE rpc_traffic_rx counter\nrpc_traffic_rx{coin=\"BTC\"} 149\nrpc_traffic_rx{coin=\"KMD\"} 158\n\n# TYPE rpc_connection_count gauge\nrpc_connection_count{coin=\"KMD\"} 5\n\n# TYPE rpc_query_spent_time histogram\nrpc_query_spent_time_sum 4.5\nrpc_query_spent_time_count 1\n\n");
//
// assert_eq!(expected, actual.to_string());
// }
#[test]
fn test_prometheus_format() {
let mm_metrics = MetricsArc::new();

mm_metrics.init();

mm_counter!(mm_metrics, "rpc.traffic.tx", 62, "coin" => "BTC");
mm_counter!(mm_metrics, "rpc.traffic.rx", 105, "coin" => "BTC");

mm_counter!(mm_metrics, "rpc.traffic.tx", 30, "coin" => "BTC");
mm_counter!(mm_metrics, "rpc.traffic.rx", 44, "coin" => "BTC");

mm_counter!(mm_metrics, "rpc.traffic.tx", 54, "coin" => "KMD");
mm_counter!(mm_metrics, "rpc.traffic.rx", 158, "coin" => "KMD");

mm_gauge!(mm_metrics, "rpc.connection.count", 3.0, "coin" => "KMD");
mm_gauge!(mm_metrics, "rpc.connection.count", 5.0, "coin" => "KMD");

mm_timing!(mm_metrics,
"rpc.query.spent_time",
4.5,
"coin"=> "KMD",
"method"=>"blockchain.transaction.get");

println!("{}", mm_metrics.0.collect_prometheus_format());
}
}