EzDevInfo.com

airbrake

The official Airbrake library for Ruby on Rails. Links to other Airbrake libraries are in the ReadMe. Airbrake – The best bug tracker and error tracking software. airbrake bug tracker captures errors and aggregate the results for developer review.

Setting up Airbrake on an Ember application

How do you set up Airbrake such that it gets context information from unhandled Javascript errors that occur in an Ember application?


Source: (StackOverflow)

rescue 500 error without messing Airbrake up

I have Airbrake installed on my Rails app. However, I also want to perform some other actions when a 500 occurs. How do I rescue 500 errors without interfering with Airbrake?


Source: (StackOverflow)

Advertisements

Sidekiq/Airbrake only post exception when retries extinguished

I would like Airbrake to only be notified of errors when the retries are exhausted, but I can't seem to think of a way to implement it...

I can add a sidekiq_retries_exhausted hook to send the error to AirBrake but the only way I can think of catching the actual failures is to add a middleware that swallows the error, but then, the job will be marked as a success if there is no error... then there will never be any retries..

Hope that makes sense!


Source: (StackOverflow)

Resque + Aibrake, not seeing exceptions

I'm using the Airbrake support that comes with Resque:

require 'resque/failure/multiple'
require 'resque/failure/airbrake'
require 'resque/failure/redis'

Resque::Failure::Airbrake.configure do |config|
  config.api_key = 'xxxxx'
end

Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Airbrake]
Resque::Failure.backend = Resque::Failure::Multiple

And trying out a simple job:

class Fail
  @queue = :propagation

  def self.perform
    raise "Fail!"
  end
end

I see the error in resque-web, but it never shows up in Airbrake. What could I be doing wrong?


Source: (StackOverflow)

Rails - Logging events with tags or types and getting an email alert - best practices?

Wondering if someone could offer some best practice on logging techniques they use and maybe tagging certain events using airbrake or newrelic or loggly, or something of that nature?

For example, lets say I have events that should never hit my controller in theory, because they are protected on the front end - like a regular user being able to manage an admin. I prevent these controls from being outputted on the front end using ruby if statements. So if my controller gets hit with a request like this, then I know that either that code isn't working right, or someone is doing some hacking with the request being sent.

Either way I want to know. I just found myself writing:

#TODO: Log this. Either the front end is broken or the user is sending hacked requests

Wondering if anyone can offer some insight as to how they handle it, maybe with a third party logging tool, maybe with some sort of tag that I could set up email alerts with said tool?


Source: (StackOverflow)

airbrake don't working by Rake task

ENV

  • Rails 3.2.13
  • ruby 1.9.3p392
  • airbrake 3.1.11
  • rake, version 10.0.4

my config file and rake task file

#lib/tasks/raise.rake
namespace :raise do
  desc "raise sth"
    task :sth => :environment do
      num = 1 / 0 # should raise error
    end
  end
end

# config/initializers/airbrake.rb
Airbrake.configure do |config|
  config.rescue_rake_exceptions = true
  config.api_key = Setting.airbrake_api
end

I hope run RAILS_ENV=production rake raise:sth send message to my airbrake, but nothing happen, just output divided by 0, not anything call stack info.

please help me, thank you ~


Source: (StackOverflow)

log backtrace, rescue_from and custom error pages

hi I am trying to create custom error pages in a project of rails 3.0.20 and ruby 1.8.7

anyway in my application controller:

unless Rails.application.config.consider_all_requests_local
rescue_from Exception, :with => :render_error
rescue_from ActionController::RoutingError, ActionController::UnknownController,      ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, :with =>    :render_error_not_found
end

then the render error method:

def render_error(exception)
notify_airbrake(exception)
Rails.logger.fatal exception
Rails.logger.fatal exception.backtrace.join("\n")
respond_to do |format|
  format.html { render :template => "errors/error_500", :layout => 'layouts/application'}
  format.all { render :nothing => true, :status => 500 }
end
end

it seems that now my logs are being filled with a much longer then usual backtrace. why is that happening? is there a way to show just the "important" part of a backtrace? and is it correct to call airbrake here?

thanks


Source: (StackOverflow)

atos and dwarfdump won't symbolicate my address

I received a crash report via AirBrake.io that isn't symbolicated. Since the crash report is not in exactly the same format as an Apple crashlog I can't just drop it on XCode as usual, so I took the exact same build from my XCode archive tried to symbolicate it on the commandline. With the following result:

$ atos -o kidsapp.app/kidsapp 0x0002fc4c
0x0002fc4c (in kidsapp)

I'm absolutely sure I'm using the same build as the crash report is from. So I also tried with dwarfdump:

$ dwarfdump --lookup 0x0002fc4c --arch armv7 kidsapp.app.dSYM
----------------------------------------------------------------------
 File: kidsapp.app.dSYM/Contents/Resources/DWARF/kidsapp (armv7)
----------------------------------------------------------------------
Looking up address: 0x000000000002fc4c in .debug_info... not found.
Looking up address: 0x000000000002fc4c in .debug_frame... not found.

Also no result. Is there anything else besides using the wrong dSYM file that I could do wrong? I know it's the correct one since this is the version referred in the crash report in AirBrake and it's in my XCode archive.

Any ideas/tips are welcome!


Source: (StackOverflow)

Open sourced alternative to airbrake? [closed]

Is there an alternative open sourced version of a system like http://airbrake.io/pages/home

I would use airbrake but its purely for internal software and exception management


Source: (StackOverflow)

Service similar to Airbrake.io for java applications?

We made our own api for airbrake.io in java. This works fine but airbrake is displaying parameters and stacktraces in some kind of Rails style. This is somewhat annoying. Anyone know of similar services made for java?

Example of how data is displayed:

Parameters

{"controller"=>"", "action"=>""}

Stacktrace

/testapp/app/models/user.rb:53:in `public'
/testapp/app/controllers/users_controller.rb:14:in `index'

Source: (StackOverflow)

ERROR -- : uninitialized constant Airbrake (NameError)

I'm working on a rails 3.2.8 project, I've just installed the airbrake gem to track errors, In development I did the airbrake installation steps, then when I did the deployment with capistrano, I got the following error in the unicorn production log:

E, [2012-10-16T03:02:51.588084 #3645] ERROR -- : reaped #<Process::Status: pid 3846 exit 1> worker=3
I, [2012-10-16T03:02:51.588434 #3645]  INFO -- : worker=3 spawning...
I, [2012-10-16T03:02:51.708539 #3858]  INFO -- : worker=3 spawned pid=3858
I, [2012-10-16T03:02:51.708986 #3858]  INFO -- : Refreshing Gem list
E, [2012-10-16T03:02:52.793217 #3849] ERROR -- : uninitialized constant Airbrake (NameError)
/home/ubuntu/apps/nimrod/releases/20121011033552/config/initializers/airbrake.rb:1:in `<top (required)>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:587:in `block in <class:Engine>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/ubuntu/apps/nimrod/releases/20121011033552/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `eval'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `block in builder'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `call'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `build_app!'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:569:in `init_worker_process'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:589:in `worker_loop'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:487:in `spawn_missing_workers'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:498:in `maintain_worker_count'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:272:in `join'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/bin/unicorn:19:in `load'
/home/ubuntu/apps/nimrod/shared/bundle/ruby/1.9.1/bin/unicorn:19:in `<main>'

I've noticed the airbrake gem is installed in shared/bundle/ruby/1.9.1/gems with all other gems.

In production I'm running a Ubuntu 12.04 x64 with unicorn running with nginx and ruby 1.9.3-p194, with this gems

Using airbrake (3.1.4) 
Using capistrano (2.12.0)    
Using bundler (1.1.4) 
Using rails (3.2.8) 
Using unicorn (4.3.1) 

And also tried to stop nginx, unicorn and then start them all again, but it didn't worked

I hope someone can help me with this


Source: (StackOverflow)

Rails - NoMethodError

I am receiving NoMethodErrors when my DeltaSynWorker runs. This happens in an application that was built as a revision of a currently working application. I am not the original programmer, and I am coming at it from a Java background (I mention this because it is possible I am missing something very obvious to others). I cannot figure out why NoMethodeError is being thrown when the code is very similar to code that is currently working fine in a different web application.

The Error:

NoMethodError: undefined method `client' for #<ApiRequestBuilder:0x0000000705a8f0>

delta_sync_worker.rb

class DeltaSyncWorker < SyncWorker

  include Sidekiq::Worker
  sidekiq_options queue: "delta_syncs"

  def perform(subscriber_id, client_id)

      sleep(10)
      current_subscriber = ApiSubscriberDecorator.decorate(Subscriber.find(subscriber_id))
      Time.zone = current_subscriber.time_zone
      client = ApiClientDecorator.decorate(Client.find(client_id))
      arb = ApiRequestBuilder.new(URI.parse(SR_HOST + '/servlet/sync/process'))

      if arb.client(:subscriber => current_subscriber, :client => client)

        arb.transmit

        if arb.success?
          current_subscriber.touch(:sync_updated_at)
          decorated_client = ClientDecorator.decorate(client.model)        
          ConfirmationsSyncWorker.perform_in(1.hours, current_subscriber.id)
        else
          error_params = {:subscriber => current_subscriber.id, :response_body =>            arb.response.body, :request_body => arb.request.body, :sync_type => "DeltaSyncWorker"}
          Airbrake.notify(:error_class => "sync_error", :error_message => "Sync Error: #{arb.response.message}", :params => error_params)
        end
      end
    end
  end

api_request_builder.rb

require 'nokogiri'
class ApiRequestBuilder < AbstractController::Base
  include AbstractController::Rendering
  include AbstractController::Layouts
  include AbstractController::Helpers
  include AbstractController::Translation
  include AbstractController::AssetPaths

  self.view_paths = "app/api"

  attr_accessor :request_body, :request, :response, :append_request_headers, :request_method, :url

  def initialize(url, *args)
    @url = url
    if args
      args.each do |arg|
        arg.each_pair{ |k,v| instance_variable_set("@#{k.to_s}", v) }
      end
    end
  end

  # this will search for an api request template in api/requests, render that template and set any instance variables
  def method_missing(meth, *args, &block)

    if lookup_context.template_exists?("requests/#{meth.to_s}")

      if args
        args.each do |arg|
          arg.each_pair{|k,v| instance_variable_set("@#{k.to_s}", v) }
        end
      end

      @request_body = (render :template => "requests/#{meth.to_s}")
    else
      super
    end

  end

  def transmit
    @request_method ||= "Post"
    @request = "Net::HTTP::#{@request_method}".constantize.new(@url.path)
    @request['x-ss-user'] = @subscriber.sr_user if @subscriber &&        @subscriber.sr_user.present?
    @request['x-ss-pwd'] =  @subscriber.sr_password if @subscriber && @subscriber.sr_password.present?

    unless @append_request_headers.nil?
      @append_request_headers.each_pair{ |k,v| @request[k] = v }
    end
    @request.body = @request_body if request_body? && @request.request_body_permitted?

    @http = Net::HTTP.new(@url.host, @url.port)
    @http.use_ssl = true
    @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    @response = @http.request(@request)

  end

  def success?
    if @response.code == 200.to_s
      return true
    else
      return false
    end
  end

  def request_body?
    unless @request_body.nil?
      return true
    else
      return false
    end
  end
end

I have been looking at other NoMethodError questions here, but I cannot find an answer I feel applies to my situation. Any help is greatly appreciated. Thanks!


Source: (StackOverflow)

airbrake notify_airbrake method not working in controller

In airbrake controller this code works (gives notification) rescue => ex Airbrake.notify but

rescue => ex
    notify_airbrake(ex)
end

Doesn't give a any airbrake notification.how to make notify_airbrake(ex) to work


Source: (StackOverflow)

Can't adapt the airbrake gem to a Sinatra app

I am using the airbrake gem like so:

require 'airbrake'

Airbrake.configure do |config|
  config.api_key = 'XXXXX'
  config.development_environments = ["development", "test", "cucumber"]
end

use Airbrake::Rack
enable :raise_errors

but it still sends airbrake notifications in development.

My environment is saved in ENV['RACK_ENV'].

I don't want to hack my way into this, is there an "outside" solution?

Also, I do want to raise exceptions in development - I just don't want them to be sent to airbrake..


Source: (StackOverflow)

Error reporting when sending emails with delayed_job

What's the proper way to get error reports, when using a tool like AirBrake or ExceptionNotifier from mailing delayed jobs?

I tried to creating my own delayed job class, but the mail object created by Mailer.welcome() (or similar) is not serialized correctly. I also tried adding an error(job, exception) method to the PerformableMailer and PerformableMethod classes, but I got more errors generally related to serializing I believe. I tried both psych and sych for the serialization.


Source: (StackOverflow)