From e1e4040c1504f15d97ebe256b3289642fd55bb5c Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 15 Feb 2020 13:14:21 +0000 Subject: [PATCH] metrics --- Cargo.lock | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/main.rs | 5 ++++- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f827ef7..8a3a82d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,6 +128,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" +[[package]] +name = "fnv" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" + [[package]] name = "fsevent" version = "0.4.0" @@ -478,6 +484,7 @@ dependencies = [ "pathfinding", "rocket", "rocket_contrib", + "rocket_prometheus", "serde", "serde_derive", "serde_json", @@ -501,6 +508,32 @@ dependencies = [ "unicode-xid 0.2.0", ] +[[package]] +name = "prometheus" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5567486d5778e2c6455b1b90ff1c558f29e751fc018130fa182e15828e728af1" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "protobuf", + "quick-error", + "spin", +] + +[[package]] +name = "protobuf" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6686ddd96a8dbe2687b5f2a687b2cfb520854010ec480f2d74c32e7c9873d3c5" + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + [[package]] name = "quote" version = "0.6.13" @@ -602,6 +635,16 @@ dependencies = [ "unicode-xid 0.1.0", ] +[[package]] +name = "rocket_prometheus" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e4954e976f59c2ef8766aaa65352c8e6776f86cf99943f5f45785dab4160f8" +dependencies = [ + "prometheus", + "rocket", +] + [[package]] name = "ryu" version = "1.0.2" @@ -672,6 +715,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + [[package]] name = "state" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index 10931cc..4e66479 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ edition = "2018" [dependencies] rocket = "0" rocket_contrib = "0" +rocket_prometheus = "0.3" serde = "1.0" serde_json = "1.0" serde_derive = "1.0" diff --git a/src/main.rs b/src/main.rs index adbce66..415d153 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,7 @@ fn find_path( match path { None => return None, Some(x) => { - return Some(x.0); + return Some(x.0.iter().rev().cloned().collect()); } } } @@ -154,7 +154,10 @@ fn find_target<'a>(gs: &'a battlesnake::SnakeRequest) -> &'a battlesnake::Coord fn main() { let map = HashMap::::new(); let mutex_map = Mutex::from(map); + let prometheus = rocket_prometheus::PrometheusMetrics::new(); rocket::ignite() + .attach(prometheus.clone()) + .mount("/metrics", prometheus) .mount("/", routes![index, start, ping, make_move, end,]) .manage(mutex_map) .launch();