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

New metric for empty coverage #3610

Merged
11 changes: 8 additions & 3 deletions src/agent/onefuzz-task/src/tasks/coverage/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use onefuzz_file_format::coverage::{
};
use onefuzz_result::job_result::JobResultData;
use onefuzz_result::job_result::{JobResultSender, TaskJobResultClient};
use onefuzz_telemetry::{event, warn, Event::coverage_data, Event::coverage_failed, EventData};
use onefuzz_telemetry::{
event, warn, Event::coverage_data, Event::coverage_empty, Event::coverage_failed, EventData,
};
use storage_queue::{Message, QueueClient};
use tokio::fs;
use tokio::sync::RwLock;
Expand Down Expand Up @@ -148,7 +150,6 @@ impl CoverageTask {

info!("report initial coverage");
context.report_coverage_stats().await;

context.heartbeat.alive();

for dir in &self.config.readonly_inputs {
Expand All @@ -174,7 +175,6 @@ impl CoverageTask {
context.save_and_sync_coverage().await?;
}

info!("report coverage");
context.report_coverage_stats().await;

context.heartbeat.alive();
Expand Down Expand Up @@ -308,6 +308,11 @@ impl<'a> TaskContext<'a> {

async fn try_record_input(&mut self, input: &Path) -> Result<()> {
let coverage = self.record_impl(input).await?;
let coverage_stats = CoverageStats::new(&coverage);
if coverage_stats.covered == 0 {
event!(coverage_empty; EventData::Path = input.display().to_string());
metric!(coverage_empty; 1.0; EventData::Path = input.display().to_string());
}
let mut self_coverage = RwLock::write(&self.coverage).await;
self_coverage.merge(&coverage);
Ok(())
Expand Down
2 changes: 2 additions & 0 deletions src/agent/onefuzz-telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub enum Event {
task_start,
coverage_data,
coverage_failed,
coverage_empty,
new_result,
new_crashdump,
new_coverage,
Expand All @@ -94,6 +95,7 @@ impl Event {
Self::task_start => "task_start",
Self::coverage_data => "coverage_data",
Self::coverage_failed => "coverage_failed",
Self::coverage_empty => "coverage_empty",
Self::new_coverage => "new_coverage",
Self::new_crashdump => "new_crashdump",
Self::new_result => "new_result",
Expand Down
Loading