add missing telemetry relating to reports & tools (#203)

This commit is contained in:
bmc-msft
2020-10-26 09:59:02 -04:00
committed by GitHub
parent 18cc45ac56
commit bc2a3f816f
3 changed files with 29 additions and 3 deletions

View File

@ -109,8 +109,18 @@ impl Config {
Config::GenericGenerator(_) => "generic_generator", Config::GenericGenerator(_) => "generic_generator",
}; };
match self {
Config::GenericGenerator(c) => {
event!(task_start; EventData::Type = event_type, EventData::ToolName = c.generator_exe.clone());
}
Config::GenericAnalysis(c) => {
event!(task_start; EventData::Type = event_type, EventData::ToolName = c.analyzer_exe.clone());
}
_ => {
event!(task_start; EventData::Type = event_type); event!(task_start; EventData::Type = event_type);
} }
}
}
pub async fn run(self) -> Result<()> { pub async fn run(self) -> Result<()> {
telemetry::set_property(EventData::JobId(self.common().job_id)); telemetry::set_property(EventData::JobId(self.common().job_id));

View File

@ -6,7 +6,9 @@ use onefuzz::{
asan::AsanLog, asan::AsanLog,
blob::{BlobClient, BlobContainerUrl, BlobUrl}, blob::{BlobClient, BlobContainerUrl, BlobUrl},
syncdir::SyncedDir, syncdir::SyncedDir,
telemetry::Event::{new_report, new_unable_to_reproduce, new_unique_report},
}; };
use reqwest::StatusCode;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::path::PathBuf; use std::path::PathBuf;
use uuid::Uuid; use uuid::Uuid;
@ -58,16 +60,21 @@ async fn upload_deduped(report: &CrashReport, container: &BlobContainerUrl) -> R
let blob = BlobClient::new(); let blob = BlobClient::new();
let deduped_name = report.unique_blob_name(); let deduped_name = report.unique_blob_name();
let deduped_url = container.blob(deduped_name).url(); let deduped_url = container.blob(deduped_name).url();
blob.put(deduped_url) let result = blob
.put(deduped_url)
.json(report) .json(report)
// Conditional PUT, only if-not-exists. // Conditional PUT, only if-not-exists.
.header("If-None-Match", "*") .header("If-None-Match", "*")
.send() .send()
.await?; .await?;
if result.status() != StatusCode::NOT_MODIFIED {
event!(new_unique_report;);
}
Ok(()) Ok(())
} }
async fn upload_report(report: &CrashReport, container: &BlobContainerUrl) -> Result<()> { async fn upload_report(report: &CrashReport, container: &BlobContainerUrl) -> Result<()> {
event!(new_report;);
let blob = BlobClient::new(); let blob = BlobClient::new();
let url = container.blob(report.blob_name()).url(); let url = container.blob(report.blob_name()).url();
blob.put(url).json(report).send().await?; blob.put(url).json(report).send().await?;
@ -75,8 +82,8 @@ async fn upload_report(report: &CrashReport, container: &BlobContainerUrl) -> Re
} }
async fn upload_no_repro(report: &NoCrash, container: &BlobContainerUrl) -> Result<()> { async fn upload_no_repro(report: &NoCrash, container: &BlobContainerUrl) -> Result<()> {
event!(new_unable_to_reproduce;);
let blob = BlobClient::new(); let blob = BlobClient::new();
let url = container.blob(report.blob_name()).url(); let url = container.blob(report.blob_name()).url();
blob.put(url).json(report).send().await?; blob.put(url).json(report).send().await?;
Ok(()) Ok(())

View File

@ -19,6 +19,9 @@ pub enum Event {
new_coverage, new_coverage,
runtime_stats, runtime_stats,
process_stats, process_stats,
new_report,
new_unique_report,
new_unable_to_reproduce,
} }
impl Event { impl Event {
@ -30,6 +33,9 @@ impl Event {
Self::new_result => "new_result", Self::new_result => "new_result",
Self::runtime_stats => "runtime_stats", Self::runtime_stats => "runtime_stats",
Self::process_stats => "process_stats", Self::process_stats => "process_stats",
Self::new_report => "new_report",
Self::new_unique_report => "new_unique_report",
Self::new_unable_to_reproduce => "new_unable_to_reproduce",
} }
} }
} }
@ -64,6 +70,7 @@ pub enum EventData {
CoveragePathsFound(u64), CoveragePathsFound(u64),
CoveragePathsImported(u64), CoveragePathsImported(u64),
CoverageMaxDepth(u64), CoverageMaxDepth(u64),
ToolName(String),
} }
impl EventData { impl EventData {
@ -97,6 +104,7 @@ impl EventData {
Self::CoveragePathsImported(x) => ("coverage_paths_imported", x.to_string()), Self::CoveragePathsImported(x) => ("coverage_paths_imported", x.to_string()),
Self::CoverageMaxDepth(x) => ("coverage_paths_depth", x.to_string()), Self::CoverageMaxDepth(x) => ("coverage_paths_depth", x.to_string()),
Self::Coverage(x) => ("coverage", x.to_string()), Self::Coverage(x) => ("coverage", x.to_string()),
Self::ToolName(x) => ("tool_name", x.to_owned()),
} }
} }
@ -132,6 +140,7 @@ impl EventData {
Self::CoveragePathsImported(_) => true, Self::CoveragePathsImported(_) => true,
Self::CoverageMaxDepth(_) => true, Self::CoverageMaxDepth(_) => true,
Self::Coverage(_) => true, Self::Coverage(_) => true,
Self::ToolName(_) => true,
} }
} }
} }