Skip to content

Commit

Permalink
add counters for docker command runner
Browse files Browse the repository at this point in the history
[ci skip-build-wheels]
  • Loading branch information
Tom Dyas committed Sep 24, 2022
1 parent 7ecbf89 commit eba9c68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/rust/engine/process_execution/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use nails::execution::ExitCode;
use parking_lot::Mutex;
use store::Store;
use task_executor::Executor;
use workunit_store::{in_workunit, RunningWorkunit};
use workunit_store::{in_workunit, Metric, RunningWorkunit};

use crate::local::{
apply_chroot, create_sandbox, prepare_workdir, setup_run_sh_script, CapturedWorkdir, ChildOutput,
Expand Down Expand Up @@ -326,7 +326,7 @@ impl super::CommandRunner for CommandRunner {
// NB: See engine::nodes::NodeKey::workunit_level for more information on why this workunit
// renders at the Process's level.
desc = Some(req.description.clone()),
|_workunit| async move {
|workunit| async move {
let mut workdir = create_sandbox(
self.executor.clone(),
&self.work_dir_base,
Expand Down Expand Up @@ -376,8 +376,7 @@ impl super::CommandRunner for CommandRunner {
)
.await?;

// DOCKER-TODO: Add a metric for local docker execution?
// workunit.increment_counter(Metric::LocalExecutionRequests, 1);
workunit.increment_counter(Metric::DockerExecutionRequests, 1);

let res = self
.run_and_capture_workdir(
Expand All @@ -403,6 +402,11 @@ impl super::CommandRunner for CommandRunner {
})
.await;

match &res {
Ok(_) => workunit.increment_counter(Metric::DockerExecutionSuccess, 1),
Err(_) => workunit.increment_counter(Metric::DockerExecutionErrors, 1),
}

if self.keep_sandboxes == KeepSandboxes::Always
|| self.keep_sandboxes == KeepSandboxes::OnFailure
&& res.as_ref().map(|r| r.exit_code).unwrap_or(1) != 0
Expand Down
3 changes: 3 additions & 0 deletions src/rust/engine/workunit_store/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pub enum Metric {
RemoteStoreMissingDigest,
/// Number of times that we backtracked due to missing digests.
BacktrackAttempts,
DockerExecutionRequests,
DockerExecutionSuccess,
DockerExecutionErrors,
}

impl Metric {
Expand Down

0 comments on commit eba9c68

Please sign in to comment.