fn with_timeout<T, R>(
        timeout: Duration,
        action_name: &'static str,
        maybe_provider: &mut Option<T>,
        action: fn(&T) -> R,
    ) where
        T: Send + 'static,
        R: InspectResults + Send + 'static,
    {
        if let Some(provider) = maybe_provider.take() {
            let (result_sender, result_receiver) = mpsc::sync_channel(1);
            let join_handle = thread::spawn(move || {
                result_sender.send((action(&provider), provider)).ok();
            });
            match result_receiver.recv_timeout(timeout) {
                Ok((results, provider)) => {
                    tracing::info!("Completed {action_name}");
                    *maybe_provider = Some(provider);
                    results.inspect_results(action_name);
                }
                Err(mpsc::RecvTimeoutError::Disconnected) => {
                    if join_handle.join().is_err() {
                        tracing::error!("Panicked while {action_name}");
                    }
                }
                Err(mpsc::RecvTimeoutError::Timeout) => {
                    tracing::warn!(?timeout, "Timed out {action_name}");
                }
            }
        } else {
            tracing::debug!("Skipped {action_name}: no provider present");
        }
    }
Performs an action on the OpenTelemetry provider. If the action times out, the provider is lost, but the control flow proceeds
(= a node doesn't hang up during shutdown).

Motivated by OpenTelemetry providers hanging up indefinitely on flushing / shutdown if the configured telemetry URL is unreachable.
core/lib/vlog/src/lib.rs