add onefuzz version & scaleset_id to telemetry from agent & supervisor (#94)

This commit is contained in:
bmc-msft
2020-10-02 23:57:46 -04:00
committed by GitHub
parent 2bb6dcbaca
commit 71439adea7
3 changed files with 19 additions and 2 deletions

View File

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

View File

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

View File

@ -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,