Skip to content

Commit

Permalink
Log for happy path tracking too
Browse files Browse the repository at this point in the history
Adding spans to narrowly enable logging for `info` levels.
  • Loading branch information
shepmaster committed Nov 12, 2024
1 parent 7d9f2e2 commit 75b9198
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions compiler/base/orchestrator/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use tokio::{
};
use tokio_stream::wrappers::ReceiverStream;
use tokio_util::{io::SyncIoBridge, sync::CancellationToken};
use tracing::{error, info_span, instrument, trace, trace_span, warn, Instrument};
use tracing::{error, info, info_span, instrument, trace, trace_span, warn, Instrument};

use crate::{
bincode_input_closed,
Expand Down Expand Up @@ -2540,14 +2540,7 @@ pub struct TerminateContainer(Option<(String, Command)>);

impl TerminateContainer {
pub fn new(name: String, command: Command) -> Self {
let was_inserted = TRACKED_CONTAINERS
.lock()
.unwrap_or_else(|e| e.into_inner())
.insert(name.clone().into());

if !was_inserted {
error!(%name, "This container was already tracked; duplicates are bad logic");
}
Self::start_tracking(&name);

Self(Some((name, command)))
}
Expand All @@ -2571,13 +2564,31 @@ impl TerminateContainer {
Ok(())
}

#[instrument]
fn start_tracking(name: &str) {
let was_inserted = TRACKED_CONTAINERS
.lock()
.unwrap_or_else(|e| e.into_inner())
.insert(name.into());

if was_inserted {
info!(%name, "Started tracking container");
} else {
error!(%name, "Started tracking container, but it was already tracked");
}
}

#[instrument]
fn stop_tracking(name: &str) {
let was_tracked = TRACKED_CONTAINERS
.lock()
.unwrap_or_else(|e| e.into_inner())
.remove(name);
if !was_tracked {
error!(%name, "Container was not in the tracking set");

if was_tracked {
info!(%name, "Stopped tracking container");
} else {
error!(%name, "Stopped tracking container, but it was not in the tracking set");
}
}

Expand Down

0 comments on commit 75b9198

Please sign in to comment.