feat(error-tracking): emit stack frames in canonical bottom-up order#160
Draft
cat-ph wants to merge 1 commit into
Draft
feat(error-tracking): emit stack frames in canonical bottom-up order#160cat-ph wants to merge 1 commit into
cat-ph wants to merge 1 commit into
Conversation
Reverse the stacktrace frames emitted by the logger handler so that `$exception_list[].stacktrace.frames` follows the canonical cross-SDK wire order: frames[0] is the outermost entry point and the last frame is the crash site. Aligns the Elixir SDK with the cross-SDK stack frame ordering standard.
|
Reviews (1): Last reviewed commit: "feat(error-tracking): emit stack frames ..." | Re-trigger Greptile |
Contributor
posthog-elixir Compliance ReportDate: 2026-07-03 00:36:21 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostHog's error tracking expects a single canonical stack-frame order across every SDK so the ingestion pipeline can fingerprint, group, and display exceptions consistently. The canonical wire order for
$exception_list[].stacktrace.framesis bottom-up:frames[0]is the outermost entry point and the last frame is the crash site.The Elixir SDK's logger handler built frames directly from
__STACKTRACE__, which is innermost-first (crash site first). This is the reverse of the canonical order, so Elixir exceptions were emitted upside-down relative to the other SDKs.Part of cross-SDK stack-frame-order standardization: PostHog/sdk-specs#11
Change
lib/posthog/handler.ex,do_stacktrace/3now reverses the frame list it builds from__STACKTRACE__, so the emittedframesare bottom-up (entry point first, crash site last).do_stacktrace/3is untouched; only list order flips.context_line/pre_context/post_context) stay attached to their own frames; only the order of the list changes.$exception_listordering is unchanged (already canonical:[0]= outermost/reported exception).stacktrace/3clause that emits onesynthetic: trueframe) is unaffected: a single-frame list is trivially canonical, and nothing in that path assumes crash-first order.Tests
test/posthog/handler_test.exsto expect bottom-up frames. Head-matches that pinned the crash site as the first frame were converted to tail assertions (List.last/1/Enum.take(frames, -3)).Task.Supervised.invoke_mfa/2) and the last frame is the crash site (anonymous fn/0 in LoggerHandlerKit.Act.task_error/1).mix test: 308 passed, 18 excluded.mix format --check-formatted: clean.Coordination
This is a breaking wire-order change for the frames array. It should be merged/released only after the pipeline normalization gate (cymbal) is live, so that exceptions ingested during the transition are normalized to a single canonical order regardless of which SDK version produced them.
Released as a MINOR version bump so the pipeline can gate normalization on
$lib_version.Note: the pipeline currently has no dedicated Elixir stack handler; that gap is tracked in the spec PR above.