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,7 +109,17 @@ impl Config {
Config::GenericGenerator(_) => "generic_generator",
};
event!(task_start; EventData::Type = event_type);
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);
}
}
}
pub async fn run(self) -> Result<()> {

View File

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