Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
fix: reverse our filled in stack trace order
Browse files Browse the repository at this point in the history
frames should be sorted from oldest to newest despite raven's
iter_stack_frames

Closes #1134
  • Loading branch information
pjenvey committed Feb 13, 2018
1 parent ffd3a8d commit 73338ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions autopush/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ def raven_log(self, event):
extra = dict()
tb = f.getTracebackObject()
if not tb:
# include the current stack for at least some context
stack = list(iter_stack_frames())[4:] # approx.
# include the current stack for at least some
# context. sentry's expecting that "Frames should be
# sorted from oldest to newest."
stack = reversed(list(iter_stack_frames())[5:]) # approx.
extra = dict(no_failure_tb=True)
extra.update(
log_format=event.get('log_format'),
Expand Down
11 changes: 6 additions & 5 deletions autopush/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ def check():
return

assert len(logged) == 1
# Ensure a top level stacktrace was included
stacktrace = logged[0]['stacktrace']
assert any(
filename == f['abs_path'] and testname == f['function']
for f in stacktrace['frames'])
# Ensure a stacktrace was included w/ the current frame as
# the last entry
frames = logged[0]['stacktrace']['frames']
last = frames[-1]
assert last['abs_path'] == filename
assert last['function'] == testname

self._port.stopListening()
pl.stop()
Expand Down

0 comments on commit 73338ac

Please sign in to comment.