Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

perf(error-tracking): serialize cymbal response without a Value tree (#67217)

Catalin Irimie1a82d23a8f18
diff --git a/rust/cymbal/src/modes/processing/router/event.rs b/rust/cymbal/src/modes/processing/router/event.rs
index c5871107176e..95efd61714cf 100644
--- a/rust/cymbal/src/modes/processing/router/event.rs
+++ b/rust/cymbal/src/modes/processing/router/event.rs
@@ -77,20 +77,9 @@ impl IntoResponse for ProcessEventsError {
impl IntoResponse for Batch<Option<AnyEvent>> {
fn into_response(self) -> axum::response::Response {
- match serde_json::to_value(Vec::from(self)) {
- Ok(value) => (StatusCode::OK, Json(value)).into_response(),
- Err(e) => {
- warn!("Failed to serialize response: {}", e);
- (
- StatusCode::INTERNAL_SERVER_ERROR,
- Json(json!({
- "error": "Failed to serialize response",
- "details": e.to_string()
- })),
- )
- .into_response()
- }
- }
+ // `Json` serializes straight into the response body, so hand it the events
+ // directly rather than first materializing an intermediate `serde_json::Value`.
+ (StatusCode::OK, Json(Vec::from(self))).into_response()
}
}