Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
add onefuzz version & scaleset_id to telemetry from agent & supervisor (
Browse files Browse the repository at this point in the history
  • Loading branch information
bmc-msft authored Oct 3, 2020
1 parent 2bb6dcb commit 71439ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/agent/onefuzz-agent/src/tasks/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 6 additions & 1 deletion src/agent/onefuzz-supervisor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -120,6 +120,11 @@ fn load_config(opt: RunOpt) -> Result<StaticConfig> {

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);

Expand Down
8 changes: 8 additions & 0 deletions src/agent/onefuzz/src/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 71439ad

Please sign in to comment.