diff --git a/src/agent/onefuzz-agent/src/tasks/config.rs b/src/agent/onefuzz-agent/src/tasks/config.rs index 8dc5280ef..c0dc1e94f 100644 --- a/src/agent/onefuzz-agent/src/tasks/config.rs +++ b/src/agent/onefuzz-agent/src/tasks/config.rs @@ -6,7 +6,7 @@ use crate::tasks::{analysis, coverage, fuzz, heartbeat::*, merge, report}; use anyhow::Result; use onefuzz::{ blob::BlobContainerUrl, - machine_id::get_machine_id, + machine_id::{get_machine_id, get_scaleset_name}, telemetry::{self, Event::task_start, EventData}, }; use reqwest::Url; @@ -113,6 +113,10 @@ impl Config { telemetry::set_property(EventData::JobId(self.common().job_id)); telemetry::set_property(EventData::TaskId(self.common().task_id)); telemetry::set_property(EventData::MachineId(get_machine_id().await?)); + telemetry::set_property(EventData::Version(env!("ONEFUZZ_VERSION").to_string())); + if let Ok(scaleset) = get_scaleset_name().await { + telemetry::set_property(EventData::ScalesetId(scaleset)); + } info!("agent ready, dispatching task"); self.report_event(); diff --git a/src/agent/onefuzz-supervisor/src/main.rs b/src/agent/onefuzz-supervisor/src/main.rs index 77ce4ee79..8d3717cef 100644 --- a/src/agent/onefuzz-supervisor/src/main.rs +++ b/src/agent/onefuzz-supervisor/src/main.rs @@ -16,7 +16,7 @@ use std::path::PathBuf; use anyhow::Result; use onefuzz::{ - machine_id::get_machine_id, + machine_id::{get_machine_id, get_scaleset_name}, telemetry::{self, EventData}, }; use structopt::StructOpt; @@ -120,6 +120,11 @@ fn load_config(opt: RunOpt) -> Result { async fn run_agent(config: StaticConfig) -> Result<()> { telemetry::set_property(EventData::MachineId(get_machine_id().await?)); + telemetry::set_property(EventData::Version(env!("ONEFUZZ_VERSION").to_string())); + if let Ok(scaleset) = get_scaleset_name().await { + telemetry::set_property(EventData::ScalesetId(scaleset)); + } + let registration = config::Registration::create_managed(config.clone()).await?; verbose!("created managed registration: {:?}", registration); diff --git a/src/agent/onefuzz/src/telemetry.rs b/src/agent/onefuzz/src/telemetry.rs index 9247913d4..bd8061f80 100644 --- a/src/agent/onefuzz/src/telemetry.rs +++ b/src/agent/onefuzz/src/telemetry.rs @@ -39,7 +39,9 @@ pub enum EventData { WorkerId(u64), JobId(Uuid), TaskId(Uuid), + ScalesetId(String), MachineId(Uuid), + Version(String), CommandLine(String), Type(String), Mode(String), @@ -67,8 +69,10 @@ pub enum EventData { impl EventData { pub fn as_values(&self) -> (&str, String) { match self { + Self::Version(x) => ("version", x.to_string()), Self::JobId(x) => ("job_id", x.to_string()), Self::TaskId(x) => ("task_id", x.to_string()), + Self::ScalesetId(x) => ("scaleset_id", x.to_string()), Self::MachineId(x) => ("machine_id", x.to_string()), Self::CommandLine(x) => ("command_line", x.to_owned()), Self::Type(x) => ("event_type", x.to_owned()), @@ -98,9 +102,13 @@ impl EventData { pub fn can_share(&self) -> bool { match self { + // TODO: Request CELA review of Version, as having this for central stats + // would be useful to track uptake of new releases + Self::Version(_) => false, Self::TaskId(_) => true, Self::JobId(_) => true, Self::MachineId(_) => true, + Self::ScalesetId(_) => false, Self::CommandLine(_) => false, Self::Path(_) => false, Self::Type(_) => true,