Code Monkey home page Code Monkey logo

airbrake-api's Introduction

Airbrake API Build Status Dependency Status

A ruby client for the Airbrake API

Changes in 4.0

AirbrakeAPI has been completely rewritten in 4.0. Why the high version number? This was the first gem I ever wrote and it's wandered a path that started with ActiveResource, followed by HTTParty, and now Faraday. Along the way, AirbrakeAPI has lost it's ActiveRecord-like syntax for a more concise and simple API. Instead of using classes such as AirbrakeAPI::Error, the entire API is contained within AirbrakeAPI::Client.

The following classes and their methods are now deprecated:

  • AirbrakeAPI::Error
  • AirbrakeAPI::Notice
  • AirbrakeAPI::Project

While your code will continue to work using the old API, they will ultimately be removed in favor of AirbrakeAPI::Client.

Configuration

AirbrakeAPI can be configured by passing a hash to the configure method:

AirbrakeAPI.configure(:account => 'anapp', :auth_token => 'abcdefg', :secure => true)

or via a block:

AirbrakeAPI.configure do |config|
  config.account = 'anapp'
  config.auth_token = 'abcdefg'
  config.secure = true
end

Note: Airbrake's API utilizes a separate 'auth_token' than the API Key that is used to configure the Airbrake tracker. Your 'auth_token' is found on the bottom of the user settings page.

Finding Errors

Errors are paginated, the API responds with 25 at a time, pass an optional params hash for additional pages:

AirbrakeAPI.errors
AirbrakeAPI.errors(:page => 2)

To find an individual error, you can find by ID:

AirbrakeAPI.error(error_id)

Finding Notices

Find all notices of an error:

AirbrakeAPI.notices(error_id)

Notices may be paginated. If you don't want to retrieve all notices and merely want a specific page:

AirbrakeAPI.notices(error_id, :page => 3)

Find an individual notice:

AirbrakeAPI.notice(notice_id, error_id)

To resolve an error via the API:

AirbrakeAPI.update(1696170, :group => { :resolved => true})

Recreate an error:

STDOUT.sync = true
AirbrakeAPI.notices(error_id) do |batch|
  batch.each do |notice|
    result = system "curl --silent '#{notice.request.url}' > /dev/null"
    print (result ? '.' : 'F')
  end
end

Projects

To retrieve a list of projects:

AirbrakeAPI.projects

Deployments

To retrieve a list of deployments:

AirbrakeAPI.deploys(project_id)

Connecting to more than one account

While module-based configuration will work in most cases, if you'd like to simultaneously connect to more than one account at once, you can create instances of AirbrakeAPI::Client to do so:

client = AirbrakeAPI::Client.new(:account => 'myaccount', :auth_token => 'abcdefg', :secure => true)
altclient = AirbrakeAPI::Client.new(:account => 'anotheraccount', :auth_token => '123456789', :secure => false)

client.errors

altclient.projects

Responses

If an error is returned from the API, an AirbrakeError exception will be raised. Successful responses will return a Hashie::Mash object based on the data from the response.

Contributors

airbrake-api's People

Contributors

stve avatar grosser avatar sylvain avatar robinroestenburg avatar benliscio avatar bgreenlee avatar rjpaskin avatar sargegoodweather avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.