Skip to content

Stracktrace frames should strip the project_dir from abs_path for filenames #288

@dannyfallon

Description

@dannyfallon

In the filename method you're currently using the $LOAD_PATH array to determine if you can strip the start of the path for the current stacktrace frame. In Rails applications this presents some disadvantages, all related to grouping errors in Sentry

By not including the Rails root or project_dir when attempting to strip prefixes from the absolute path you end up using the full path for errors in places such as views, initialisers etc. This presents a problem if your path contains a variable, for example the timestamp or the SHA for the current version. You essentially end up polluting your sentry list with errors that should be grouped together. Right now we're monkeypatching the filename method to work around this issue

In a bit of a tangent, perhaps using the full $LOAD_PATH is also causing some unintended problems for Rails apps. The Rails autoloader will add some paths such as /app/models, /app/controllers and /lib by default. Imagine a scenario where you've a model named conversation.rb and you've a lib of the same name. The filename for an error that happens in either will be the same, so the culprit will be the same. This presents issues in the Sentry UI listing, both errors have the same culprit (conversation.rb). It also makes things difficult when viewing the backtrace, which doesn't appear to expose the abs_path in an easy way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions