Skip to content
forked from russ/bugsnag

Report exceptions in production from crystal http servers to Bugsnag.

License

Notifications You must be signed in to change notification settings

jwoertink/bugsnag

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bugsnag

Report exceptions in production from crystal http servers to Bugsnag.

Installation

Add this to your application's shard.yml:

dependencies:
  bugsnag:
    github: russ/bugsnag

Usage

  • This is meant to catch exceptions in a compiled production environment.
  • Dont use spawn to call Bugsnag.report, the http request sent to bugsnag will be done in a separate fiber. Building the report needs the context to remain open, and if Bugsnag.report is called in a spawn you will get a closed pipe error.
require "bugsnag"

Bugsnag.config do |conf|
  conf.api_key = ENV["BUGSNAG_API_KEY"] # is automatically set by this environment variable if not specified
  conf.name = "Application Name"
  conf.version = "1.0"
  conf.url = "https://my-website.com/"
  conf.release_stage = "production"
end

# In your middleware

class MyMiddlware < MyFrameworkHandler
  def call(context)
    begin
      call_next(context)
    rescue ex
      Bugsnag.report(context, ex)
      raise ex
    end
  end
end

Optionally, you can customize the event object by passing a block to report.

Bugsnag.report(context, ex) do |event|
  event.user = Bugsnag::User.new(id: "1", name: "Foo", email: "[email protected]")
end

Contributing

  1. Fork it (https://github.com/fridgerator/bugsnag/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

About

Report exceptions in production from crystal http servers to Bugsnag.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Crystal 100.0%