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): stop copying debug images per exception (#67850)

Catalin Irimie9f8338cc86ab
diff --git a/rust/cymbal/src/modes/processing/stages/resolution/frame.rs b/rust/cymbal/src/modes/processing/stages/resolution/frame.rs
index 70a4b814c130..f76265c4cbbb 100644
--- a/rust/cymbal/src/modes/processing/stages/resolution/frame.rs
+++ b/rust/cymbal/src/modes/processing/stages/resolution/frame.rs
@@ -29,7 +29,7 @@ impl FrameResolver {
move |exc, ctx| {
let debug_images = debug_images.clone();
async move {
- FrameResolver::resolve_exception_frames(team_id, exc, &debug_images, ctx)
+ FrameResolver::resolve_exception_frames(team_id, exc, debug_images, ctx)
.await
}
},
@@ -42,12 +42,11 @@ impl FrameResolver {
pub async fn resolve_exception_frames(
team_id: i32,
mut exc: Exception,
- debug_images: &[DebugImage],
+ debug_images: Arc<Vec<DebugImage>>,
ctx: ResolutionStage,
) -> Result<Exception, UnhandledError> {
exc.stack = match exc.stack {
Some(Stacktrace::Raw { frames }) => {
- let debug_images = Arc::new(debug_images.to_vec());
let frame_batches: Batch<Vec<Frame>> = Batch::from(frames)
.apply_func(
move |frame, ctx| {
@@ -111,6 +110,9 @@ impl ValueOperator for FrameResolver {
mut evt: ExceptionProperties,
ctx: ResolutionStage,
) -> OperatorResult<Self> {
+ // Clone rather than take: `$debug_images` is serialized back onto the
+ // event after resolution (rules eval and the /process response), so the
+ // field must survive this stage.
let debug_images = Arc::new(evt.debug_images.clone());
evt.exception_list = FrameResolver::resolve_exception_list_frames(
evt.team_id,
diff --git a/rust/cymbal/src/modes/resolution/service/resolve.rs b/rust/cymbal/src/modes/resolution/service/resolve.rs
index 32213ce252e5..5f0aecfe37f3 100644
--- a/rust/cymbal/src/modes/resolution/service/resolve.rs
+++ b/rust/cymbal/src/modes/resolution/service/resolve.rs
@@ -293,7 +293,7 @@ async fn resolve_one_exception(
exception
};
- FrameResolver::resolve_exception_frames(team_id, exception, &debug_images, stage)
+ FrameResolver::resolve_exception_frames(team_id, exception, Arc::new(debug_images), stage)
.await
.map_err(|err| capture_unhandled(team_id, err))
}