diff --git a/changelog.d/24532_vector_stopped_log_ordering.fix.md b/changelog.d/24532_vector_stopped_log_ordering.fix.md new file mode 100644 index 0000000000000..45f1a82eea06f --- /dev/null +++ b/changelog.d/24532_vector_stopped_log_ordering.fix.md @@ -0,0 +1,5 @@ +Fixed log message ordering on shutdown where `Vector has stopped.` was logged before components had finished draining, causing confusing output interleaved with `Waiting on running components` messages. + +A new `VectorStoppping` event was added in the place of the `VectorStopped` event. + +authors: tronboto diff --git a/src/app.rs b/src/app.rs index 6f30f85de1d20..904d42be11968 100644 --- a/src/app.rs +++ b/src/app.rs @@ -28,7 +28,9 @@ use crate::{ config::{self, ComponentConfig, ComponentType, Config, ConfigPath}, extra_context::ExtraContext, heartbeat, - internal_events::{VectorConfigLoadError, VectorQuit, VectorStarted, VectorStopped}, + internal_events::{ + VectorConfigLoadError, VectorQuit, VectorStarted, VectorStopped, VectorStopping, + }, signal::{SignalHandler, SignalPair, SignalRx, SignalTo}, topology::{ ReloadOutcome, RunningTopology, SharedTopologyController, ShutdownErrorReceiver, @@ -493,16 +495,19 @@ impl FinishedApplication { } async fn stop(topology_controller: TopologyController, mut signal_rx: SignalRx) -> ExitStatus { - emit!(VectorStopped); + emit!(VectorStopping); tokio::select! { - _ = topology_controller.stop() => ExitStatus::from_raw({ - #[cfg(windows)] - { - exitcode::OK as u32 - } - #[cfg(unix)] - exitcode::OK - }), // Graceful shutdown finished + _ = topology_controller.stop() => { + emit!(VectorStopped); + ExitStatus::from_raw({ + #[cfg(windows)] + { + exitcode::OK as u32 + } + #[cfg(unix)] + exitcode::OK + }) + }, // Graceful shutdown finished _ = signal_rx.recv() => Self::quit(), } } diff --git a/src/internal_events/process.rs b/src/internal_events/process.rs index cc3609737aea9..987724c2da18d 100644 --- a/src/internal_events/process.rs +++ b/src/internal_events/process.rs @@ -38,6 +38,18 @@ impl InternalEvent for VectorReloaded<'_> { } } +#[derive(Debug, NamedInternalEvent)] +pub struct VectorStopping; + +impl InternalEvent for VectorStopping { + fn emit(self) { + info!( + target: "vector", + message = "Vector is stopping.", + ); + } +} + #[derive(Debug, NamedInternalEvent)] pub struct VectorStopped;