Enhanced PostHog Error Tracking with Detailed Messages (#6176)

This commit is contained in:
Zane
2025-12-18 13:40:31 -08:00
committed by GitHub
parent 7ff3adcc5f
commit 70ac4b4322
8 changed files with 61 additions and 10 deletions
+7 -2
View File
@@ -534,6 +534,10 @@ impl Agent {
.dispatch_tool_call(tool_call.clone(), cancellation_token.unwrap_or_default())
.await;
result.unwrap_or_else(|e| {
crate::posthog::emit_error(
"tool_execution_failed",
&format!("{}: {}", tool_call.name, e),
);
ToolCallResult::from(Err(ErrorData::new(
ErrorCode::INTERNAL_ERROR,
e.to_string(),
@@ -1242,7 +1246,7 @@ impl Agent {
}
}
Err(ref provider_err @ ProviderError::ContextLengthExceeded(_)) => {
crate::posthog::emit_error(provider_err.telemetry_type());
crate::posthog::emit_error(provider_err.telemetry_type(), &provider_err.to_string());
compaction_attempts += 1;
if compaction_attempts >= 2 {
@@ -1279,13 +1283,14 @@ impl Agent {
break;
}
Err(e) => {
crate::posthog::emit_error("compaction_failed", &e.to_string());
error!("Compaction failed: {}", e);
break;
}
}
}
Err(ref provider_err) => {
crate::posthog::emit_error(provider_err.telemetry_type());
crate::posthog::emit_error(provider_err.telemetry_type(), &provider_err.to_string());
error!("Error: {}", provider_err);
yield AgentEvent::Message(
Message::assistant().with_text(
+4
View File
@@ -137,6 +137,10 @@ impl RetryManager {
"Maximum retry attempts ({}) exceeded",
retry_config.max_retries
);
crate::posthog::emit_error(
"retry_max_exceeded",
&format!("Max retries ({}) exceeded", retry_config.max_retries),
);
return Ok(RetryResult::MaxAttemptsReached);
}