mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
feat(telemetry): log use of map-enobufs-to-wouldblock (#9829)
In order to better track, how well our `ENOBUFS` mitigation is working, we should log the use of our feature flag to PostHog. This will give us some stats how often this is happening. That combined with the lack of error reports should give us good confidence in permanently enabling this behaviour.
This commit is contained in:
@@ -356,6 +356,9 @@ impl UdpSocket {
|
||||
if e.raw_os_error().is_some_and(|e| e == libc::ENOBUFS)
|
||||
&& firezone_telemetry::feature_flags::map_enobufs_to_would_block() =>
|
||||
{
|
||||
firezone_telemetry::analytics::feature_flag_called(
|
||||
"map-enobufs-to-wouldblock",
|
||||
);
|
||||
tracing::debug!("Encountered ENOBUFS, treating as WouldBlock");
|
||||
|
||||
Err(io::Error::from(io::ErrorKind::WouldBlock))
|
||||
|
||||
@@ -65,6 +65,36 @@ pub fn identify(release: String, account_slug: Option<String>) {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn feature_flag_called(name: impl Into<String>) {
|
||||
let Some(env) = Telemetry::current_env() else {
|
||||
tracing::debug!("Cannot send $feature_flag_called: Unknown env");
|
||||
return;
|
||||
};
|
||||
let Some(distinct_id) = Telemetry::current_user() else {
|
||||
tracing::debug!("Cannot send $feature_flag_called: Unknown user");
|
||||
return;
|
||||
};
|
||||
let feature_flag = name.into();
|
||||
|
||||
RUNTIME.spawn({
|
||||
async move {
|
||||
if let Err(e) = capture(
|
||||
"$feature_flag_called",
|
||||
distinct_id,
|
||||
env,
|
||||
FeatureFlagCalledProperties {
|
||||
feature_flag,
|
||||
feature_flag_response: "true".to_owned(),
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
tracing::debug!("Failed to log `$feature_flag_called` event: {e:#}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async fn capture<P>(
|
||||
event: impl Into<String>,
|
||||
distinct_id: String,
|
||||
@@ -137,3 +167,11 @@ struct PersonProperties {
|
||||
#[serde(rename = "$os")]
|
||||
os: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
struct FeatureFlagCalledProperties {
|
||||
#[serde(rename = "$feature_flag")]
|
||||
feature_flag: String,
|
||||
#[serde(rename = "$feature_flag_response")]
|
||||
feature_flag_response: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user