Closed henrik closed 7 years ago
Hi Henrik,
Thanks for your suggestions, I've opened some Pull Requests that should address most of them (let me know if I've left something out).
I'm still working on some Sinatra documentation, but Raygun4Ruby is already using Rack middleware, so you should be able to just use Raygun::RackExceptionInterceptor
in your Sinatra app?
Nik
Oh, cool, didn't notice that. Thanks, will try it out.
Trying it out. Maybe this pattern is useful for the docs (or would you recommend something else?):
raygun_api_key = ENV["RAYGUN_API_KEY"]
Raygun.setup do |config|
config.api_key = raygun_api_key
config.silence_reporting = !raygun_api_key
end
use Raygun::RackExceptionInterceptor
Oh, and for the middleware to work it seems your Sinatra app needs set :raise_errors, true
.
I ended up using this: https://github.com/henrik/etsy-rss/blob/master/raygun_rack.rb
Hey Henrik,
I've pushed an example here: https://github.com/MindscapeHQ/raygun4ruby/pull/13.
We're not using either of those env hash entries - so I'm not sure if they're necessary.
What do you think?
Nik
Assigning env["raygun.error_id"]
is not necessary IIRC (just consistent with other Rack stuff), but getting the exception from something like env["rack.exception"] || env["sinatra.error"]
most definitely is. Otherwise you won't get errors tracked with the default setting of set :raise_errors, false
. I had some pain trying to figure out why no exceptions were tracked until I figured that one out.
I noticed Honeybadger have Rack middleware to make Sinatra integration really easy: https://github.com/honeybadger-io/honeybadger-sinatra-example/blob/master/server.rb
And they have that example repo to show how to use it.
Your instructions on non-Rails use don't mention the API token configuration, and having to wrap everything in a block in e.g. a Sinatra app is not ideal. I suggest adding Rack middleware with instructions. Or at least instructions for the current functionality geared specifically to Sinatra apps.