aboutsummaryrefslogtreecommitdiff
path: root/metrics
diff options
context:
space:
mode:
Diffstat (limited to 'metrics')
-rw-r--r--metrics/Android.bp5
-rw-r--r--metrics/Cargo.toml1
-rw-r--r--metrics/src/controller.rs17
-rw-r--r--metrics/src/lib.rs2
-rw-r--r--metrics/src/sys.rs1
5 files changed, 12 insertions, 14 deletions
diff --git a/metrics/Android.bp b/metrics/Android.bp
index 87c2d10ff..275ec22f8 100644
--- a/metrics/Android.bp
+++ b/metrics/Android.bp
@@ -1,5 +1,6 @@
// This file is generated by cargo_embargo.
-// Do not modify this file as most changes will be overridden on upgrade.
+// Do not modify this file after the first "rust_*" or "genrule" module
+// because the changes will be overridden on upgrade.
// Content before the first "rust_*" or "genrule" module is preserved.
package {
@@ -24,6 +25,7 @@ rust_library {
"libanyhow",
"libbase_rust",
"libcfg_if",
+ "libmetrics_events",
"libmetrics_generic",
"libserde",
"libsync_rust",
@@ -49,6 +51,7 @@ rust_test {
"libanyhow",
"libbase_rust",
"libcfg_if",
+ "libmetrics_events",
"libmetrics_generic",
"libserde",
"libsync_rust",
diff --git a/metrics/Cargo.toml b/metrics/Cargo.toml
index dfb9b5e39..078509cdd 100644
--- a/metrics/Cargo.toml
+++ b/metrics/Cargo.toml
@@ -10,6 +10,7 @@ base = { path = "../base" }
cfg-if = "*"
serde = { version = "1", features = ["derive"] }
sync = { path = "../common/sync" }
+metrics_events = { path = "../metrics_events" }
metrics_product = { path = "../vendor/generic/metrics", package = "metrics_generic" }
[target.'cfg(windows)'.dependencies]
diff --git a/metrics/src/controller.rs b/metrics/src/controller.rs
index c3eb6fd24..ac64e9269 100644
--- a/metrics/src/controller.rs
+++ b/metrics/src/controller.rs
@@ -6,16 +6,14 @@
use anyhow::Result;
use base::info;
-use base::warn;
use base::EventToken;
-use base::Tube;
+use base::RecvTube;
-use crate::MetricsRequest;
use crate::RequestHandler;
/// Runs the metrics controller.
pub struct MetricsController {
- pub(crate) agents: Vec<Tube>,
+ pub(crate) agents: Vec<RecvTube>,
handler: RequestHandler,
pub(crate) closed_tubes: usize,
}
@@ -30,7 +28,7 @@ pub(crate) enum MetricsControllerToken {
}
impl MetricsController {
- pub fn new(agents: Vec<Tube>) -> Self {
+ pub fn new(agents: Vec<RecvTube>) -> Self {
Self {
agents,
handler: RequestHandler::new(),
@@ -46,13 +44,8 @@ impl MetricsController {
}
/// Handles a tube that has indicated it has data ready to read.
- pub(crate) fn on_tube_readable(&self, client: &Tube) {
- match client.recv::<MetricsRequest>() {
- Ok(req) => self.handler.handle_request(req),
- Err(e) => {
- warn!("unexpected error receiving agent metrics request: {}", e)
- }
- }
+ pub(crate) fn on_tube_readable(&self, client: &RecvTube) {
+ self.handler.handle_tube_readable(client)
}
/// Handles a closed connection, and returns a bool indicating
diff --git a/metrics/src/lib.rs b/metrics/src/lib.rs
index dd561ca11..a996d82f3 100644
--- a/metrics/src/lib.rs
+++ b/metrics/src/lib.rs
@@ -16,7 +16,7 @@ mod local_stats;
pub mod sys;
pub use controller::MetricsController;
-pub use metrics_product::MetricEventType;
+pub use metrics_events::MetricEventType;
pub use metrics_product::*;
pub type RequestHandler = MetricsRequestHandler;
diff --git a/metrics/src/sys.rs b/metrics/src/sys.rs
index e0696cf17..64f09e4e2 100644
--- a/metrics/src/sys.rs
+++ b/metrics/src/sys.rs
@@ -6,6 +6,7 @@ cfg_if::cfg_if! {
if #[cfg(windows)] {
pub mod windows;
pub use windows::*;
+ pub use metrics_events::sys::windows::*;
} else if #[cfg(any(target_os = "android", target_os = "linux"))] {
pub(crate) mod linux;
}