feat: gate telemetry behind Cargo feature flags (#8119)

Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Signed-off-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Rodolfo Olivieri
2026-03-26 13:33:43 -03:00
committed by GitHub
parent 8c8bb1051d
commit adc0e221fc
20 changed files with 111 additions and 38 deletions
+25 -19
View File
@@ -18,6 +18,7 @@ use crate::config::paths::Paths;
use crate::config::{resolve_extensions_for_new_session, Config};
use crate::conversation::message::Message;
use crate::conversation::Conversation;
#[cfg(feature = "telemetry")]
use crate::posthog;
use crate::providers::create;
use crate::recipe::Recipe;
@@ -267,6 +268,7 @@ impl Scheduler {
Ok(_) => tracing::info!("Job '{}' completed", task_job_id),
Err(ref e) => {
tracing::error!("Job '{}' failed: {}", task_job_id, e);
#[cfg(feature = "telemetry")]
crate::posthog::emit_error("scheduler_job_failed", &e.to_string());
}
}
@@ -838,6 +840,7 @@ async fn execute_job(
drop(jobs_guard);
let start_time = std::time::Instant::now();
#[cfg(feature = "telemetry")]
tokio::spawn(async move {
let mut props = HashMap::new();
props.insert(
@@ -907,25 +910,28 @@ async fn execute_job(
.apply()
.await?;
let duration_secs = start_time.elapsed().as_secs();
tokio::spawn(async move {
let mut props = HashMap::new();
props.insert(
"trigger".to_string(),
serde_json::Value::String("automated".to_string()),
);
props.insert(
"status".to_string(),
serde_json::Value::String("completed".to_string()),
);
props.insert(
"duration_seconds".to_string(),
serde_json::Value::Number(serde_json::Number::from(duration_secs)),
);
if let Err(e) = posthog::emit_event("schedule_job_completed", props).await {
tracing::debug!("Failed to send schedule telemetry: {}", e);
}
});
#[cfg(feature = "telemetry")]
{
let duration_secs = start_time.elapsed().as_secs();
tokio::spawn(async move {
let mut props = HashMap::new();
props.insert(
"trigger".to_string(),
serde_json::Value::String("automated".to_string()),
);
props.insert(
"status".to_string(),
serde_json::Value::String("completed".to_string()),
);
props.insert(
"duration_seconds".to_string(),
serde_json::Value::Number(serde_json::Number::from(duration_secs)),
);
if let Err(e) = posthog::emit_event("schedule_job_completed", props).await {
tracing::debug!("Failed to send schedule telemetry: {}", e);
}
});
}
Ok(session.id)
}