Skip to content

Commit

Permalink
Merge pull request xaynetwork#32 from xainag/add-more-metrics
Browse files Browse the repository at this point in the history
Add more metrics
  • Loading branch information
Robert-Steiner committed Mar 4, 2020
2 parents 0ef7898 + c57e5df commit cee05b6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ authors = ["little-dude <corentinhenry@gmail.com>"]
edition = "2018"

[dependencies]
uuid = { version = "0.8.1", features = ["v4", "serde"] }
log = "0.4.8"
futures = "0.3.4"
tokio = { version = "0.2.11", features = ["full"] }
warp = "0.2.1"
derive_more = { version = "0.99.2", default-features = false, features = [ "display", "from" ] }
rand = "0.7.3"
env_logger = "0.7.1"
tarpc = { version = "0.20.0", features = [ "full" ] }
serde = { version = "1.0.104", features = [ "derive" ] }
pyo3 = "0.9.0-alpha.1"
tokio-serde = { version = "0.6.0", features = [ "json" ] }
futures-retry = "0.4.0"
stubborn-io = "0.1.8"
bytes = "0.5.4"
config = "0.10.1"
clap = "2.33.0"
influxdb = "0.0.6"
uuid = { version = "0.8.1", features = ["v4", "serde"] } # Apache-2.0 OR MIT
log = "0.4.8" # Apache-2.0 OR MIT
futures = "0.3.4" # Apache-2.0 OR MIT
tokio = { version = "0.2.11", features = ["full"] } # MIT
warp = "0.2.1" # MIT
derive_more = { version = "0.99.2", default-features = false, features = [ "display", "from" ] } # MIT
rand = "0.7.3" # Apache-2.0 OR MIT
env_logger = "0.7.1" # Apache-2.0 OR MIT
tarpc = { version = "0.20.0", features = [ "full" ] } # MIT
serde = { version = "1.0.104", features = [ "derive" ] } # Apache-2.0 OR MIT
pyo3 = "0.9.0-alpha.1" # Apache-2.0
tokio-serde = { version = "0.6.0", features = [ "json" ] } # Apache-2.0 OR MIT
futures-retry = "0.4.0" # Apache-2.0 OR MIT
stubborn-io = "0.1.8" # MIT
bytes = "0.5.4" # MIT
config = "0.10.1" # Apache-2.0 OR MIT
clap = "2.33.0" # MIT
influxdb = "0.0.6" # MIT

[[bin]]
name = "coordinator"
Expand Down
4 changes: 4 additions & 0 deletions src/coordinator/core/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ impl Protocol {
pub fn next_event(&mut self) -> Option<Event> {
self.events.pop_front()
}

pub fn get_current_round(&self) -> u32 {
self.current_round
}
}

impl FederatedLearningSettings {
Expand Down
24 changes: 22 additions & 2 deletions src/coordinator/core/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,40 @@ where
let metric_store = self.metric_store.clone();
let counter_selected = self.protocol.counters().selected;
let counter_waiting = self.protocol.counters().waiting;
let counter_done = self.protocol.counters().done;
let counter_done_inactive = self.protocol.counters().done_and_inactive;
let counter_ignored = self.protocol.counters().ignored;
let current_round = self.protocol.get_current_round();

tokio::spawn(async move {
metric_store
.write(
MetricOwner::Coordinator,
vec![
(
String::from("number_of_selected_participants"),
"number_of_selected_participants",
Type::SignedInteger(counter_selected.try_into().unwrap()),
),
(
String::from("number_of_waiting_participants"),
"number_of_waiting_participants",
Type::SignedInteger(counter_waiting.try_into().unwrap()),
),
(
"number_of_done_participants",
Type::SignedInteger(counter_done.try_into().unwrap()),
),
(
"number_of_done_inactive_participants",
Type::SignedInteger(counter_done_inactive.try_into().unwrap()),
),
(
"number_of_ignored_participants",
Type::SignedInteger(counter_ignored.try_into().unwrap()),
),
(
"round",
Type::UnsignedInteger(current_round as u64),
),
],
)
.await;
Expand Down
2 changes: 1 addition & 1 deletion src/metric_store/metric_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl InfluxDBMetricStore {
}
}

pub async fn write(&self, metrics_owner: MetricOwner, fields: Vec<(String, Type)>) -> () {
pub async fn write(&self, metrics_owner: MetricOwner, fields: Vec<(&'static str, Type)>) -> () {
let mut write_query: WriteQuery =
Query::write_query(Timestamp::Now, metrics_owner.to_string());

Expand Down

0 comments on commit cee05b6

Please sign in to comment.