[vlc-commits] [Git][videolan/vlc][master] telegraf-rs: remove unwrap and fail when the connection fails
Alexandre Janniaux (@alexandre-janniaux)
gitlab at videolan.org
Fri Nov 13 21:20:13 UTC 2026
Alexandre Janniaux pushed to branch master at VideoLAN / VLC
Commits:
914c465b by Alexandre Janniaux at 2026-11-13T21:02:50+00:00
telegraf-rs: remove unwrap and fail when the connection fails
Current code was aborting when we could not setup the connection to the
endpoint, which is great when debugging to ensure we know why the traces
are failing, but not great for production code.
I was aware of the issue but sadly was reminded I needed to fix it by
static analysis tool (sparrow).
- - - - -
1 changed file:
- modules/logger/telegraf-rs/src/lib.rs
Changes:
=====================================
modules/logger/telegraf-rs/src/lib.rs
=====================================
@@ -45,8 +45,11 @@ impl TracerCapability for TelegrafTracer {
let endpoint_address =
std::env::var("VLC_TELEGRAF_ENDPOINT").unwrap_or(String::from("tcp://localhost:8094"));
let endpoint = Client::new(&endpoint_address)
+ .inspect_err(|err| {
+ eprintln!(" cannot connect to {}: {}", endpoint_address, err)
+ })
.map(Mutex::new)
- .unwrap();
+ .ok()?;
Some(Self { endpoint })
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/914c465b0ce30121dc15c283269c08a79b0321fe
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/914c465b0ce30121dc15c283269c08a79b0321fe
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list