Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add basic counters to docker command runner #16989

Merged
merged 2 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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::DockerExecutionSuccesses, 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,
DockerExecutionSuccesses,
DockerExecutionErrors,
}

impl Metric {
Expand Down