Skip to content

Access to event id for display #469

@heymackey

Description

@heymackey

I noticed on the Sentry web app, when an exception is raised, it displayed the event id as part of the error page, and I thought it would be nice to include in my Rails app.

I know if Raven.capture_exception is manually called, you have access to the ID, but was wondering if the automatic Rails exception handling provided by this library exposes that event id to include in a page render. Is it possible to get access to the event id when rendering dynamic error pages within Rails (via the config.exceptions_app)?

It seems that the only thing that is exposed is the exception according to Rails (via env['action_dispatch.exception']), but the Raven/Sentry event seems to already be fired and forgotten by that point.

** [Raven] Sending event [[EVENT_ID]] to Sentry
** [Raven] Raven HTTP Transport connecting to https://app.getsentry.com

1: class ErrorsController < ApplicationController
    2:   def not_found
    3:     render status: 404
    4:   end
    5:
    6:   def internal_server_error
    7:     byebug
=>  8:     render status: 500
    9:   end
   10: end

# don't have access to the [[EVENT_ID]] here
env['action_dispatch.exception']
#<ActionView::Template::Error: undefined method ...>

Any help or pointing to the right documentation would be incredibly appreciated!

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