From b5b290cd49776034ebc8b19cc31ee55486e6d6a0 Mon Sep 17 00:00:00 2001 From: Brian Caswell Date: Tue, 9 Feb 2021 15:11:25 -0500 Subject: [PATCH] add roles to agent & supervisor --- src/agent/onefuzz-agent/src/tasks/config.rs | 3 ++- src/agent/onefuzz-supervisor/src/main.rs | 3 ++- src/agent/onefuzz-telemetry/src/lib.rs | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/agent/onefuzz-agent/src/tasks/config.rs b/src/agent/onefuzz-agent/src/tasks/config.rs index 46437a6171..6bf871d8ee 100644 --- a/src/agent/onefuzz-agent/src/tasks/config.rs +++ b/src/agent/onefuzz-agent/src/tasks/config.rs @@ -5,7 +5,7 @@ use crate::tasks::{analysis, coverage, fuzz, heartbeat::*, merge, report}; use anyhow::Result; use onefuzz::machine_id::{get_machine_id, get_scaleset_name}; -use onefuzz_telemetry::{self as telemetry, Event::task_start, EventData}; +use onefuzz_telemetry::{self as telemetry, Event::task_start, EventData, Role}; use reqwest::Url; use serde::{self, Deserialize}; use std::path::PathBuf; @@ -151,6 +151,7 @@ impl Config { telemetry::set_property(EventData::MachineId(get_machine_id().await?)); telemetry::set_property(EventData::Version(env!("ONEFUZZ_VERSION").to_string())); telemetry::set_property(EventData::InstanceId(self.common().instance_id)); + telemetry::set_property(EventData::Role(Role::Agent)); let scaleset = get_scaleset_name().await?; if let Some(scaleset_name) = &scaleset { telemetry::set_property(EventData::ScalesetId(scaleset_name.to_string())); diff --git a/src/agent/onefuzz-supervisor/src/main.rs b/src/agent/onefuzz-supervisor/src/main.rs index e62875be16..c07bdc5011 100644 --- a/src/agent/onefuzz-supervisor/src/main.rs +++ b/src/agent/onefuzz-supervisor/src/main.rs @@ -26,7 +26,7 @@ use onefuzz::{ machine_id::{get_machine_id, get_scaleset_name}, process::ExitStatus, }; -use onefuzz_telemetry::{self as telemetry, EventData}; +use onefuzz_telemetry::{self as telemetry, EventData, Role}; use structopt::StructOpt; pub mod agent; @@ -171,6 +171,7 @@ async fn run_agent(config: StaticConfig) -> Result<()> { telemetry::set_property(EventData::InstanceId(config.instance_id)); telemetry::set_property(EventData::MachineId(get_machine_id().await?)); telemetry::set_property(EventData::Version(env!("ONEFUZZ_VERSION").to_string())); + telemetry::set_property(EventData::Role(Role::Supervisor)); let scaleset = get_scaleset_name().await?; if let Some(scaleset_name) = &scaleset { telemetry::set_property(EventData::ScalesetId(scaleset_name.to_string())); diff --git a/src/agent/onefuzz-telemetry/src/lib.rs b/src/agent/onefuzz-telemetry/src/lib.rs index 025784d683..a9a4b2636d 100644 --- a/src/agent/onefuzz-telemetry/src/lib.rs +++ b/src/agent/onefuzz-telemetry/src/lib.rs @@ -14,13 +14,17 @@ pub enum ClientType { #[derive(Clone, Debug, PartialEq)] pub enum Role { + Agent, Proxy, + Supervisor, } impl Role { pub fn as_str(&self) -> &'static str { match self { + Self::Agent => "agent", Self::Proxy => "proxy", + Self::Supervisor => "supervisor", } } }