sentry: Stacks are returned most-recent last.

Per [1], the sentry API returns frames sorted from oldest to newest.
As such, matching against the first filename that matches is most
likely not the right frame.

Match against the last frame with the guilty filename.

[1] https://develop.sentry.dev/sdk/event-payloads/stacktrace/
This commit is contained in:
Alex Vandiver
2020-08-17 13:40:14 -07:00
committed by Steve Howell
parent 47fe7b7d13
commit 0db311ddad
2 changed files with 3 additions and 6 deletions

View File

@@ -44,17 +44,14 @@ Traceback:
Traceback:
```javascript
const Sentry = require('@sentry/node');
Sentry.init({
dsn: 'https://redacted.ingest.sentry.io/5216640',
});
---> Sentry.withScope(function(scope) {
Sentry.withScope(function(scope) {
scope.addEventProcessor(function(event, hint) {
return event;
});
Sentry.captureException(new Error('Sample error from node.'));
---> Sentry.captureException(new Error('Sample error from node.'));
});

View File

@@ -119,7 +119,7 @@ def handle_event_payload(event: Dict[str, Any]) -> Tuple[str, str]:
if stacktrace:
exception_frame = None
for frame in stacktrace["frames"]:
for frame in reversed(stacktrace["frames"]):
if frame["filename"] == filename:
exception_frame = frame
break