Git Product home page Git Product logo

resque-pagerduty's Introduction

resque-pagerduty build status

A Resque failure backend for triggering incidents in Pagerduty.

Dependencies

Depends on Resque 1.7 or above.

Requires a subscription to Pagerduty, with at least one Pagerduty service configured with a service type of "Generic API".

Installation

To install from Rubygems:

$ gem install resque-pagerduty

To use with bundler without adding explicit require statements to your code, add the following to your Gemfile:

gem 'resque-pagerduty', :require => 'resque_pagerduty'

Documentation

Complete documentation for this gem (including this README) is available on rubydoc.info.

General information about resque failure backends is available on the resque wiki.

The Pagerduty website provides more information about the Pagerduty Integration API.

Pagerduty Configuration

To trigger incidents in the same Pagerduty service across all jobs, configure the failure backend with a Pagerduty service key:

Resque::Failure::Pagerduty.configure do |config|
  config.service_key = 'my_pagerduty_service_key'
end

This service must be set up as a "Generic API" service in Pagerduty. The service key GUID can be found on the Pagerduty service details page.

You may want to have different jobs trigger incidents in different Pagerduty services. When handling an exception, the failure backend will automatically look for a class method named pagerduty_service_key on the resque payload class, and will preferentially use that callback. If this callback does not exist on the job class, it will default to using the service_key configured on the backend itself. For example:

class MyJob
  @queue = :my_queue

  def self.pagerduty_service_key
    'my_custom_service_key'
  end

  def self.perform(my_arg)
    # Some code that could raise an exception goes here
  end
end

If the MyJob.perform method raises an exception during processing, the failure backend would use the MyJob.pagerduty_service_key instead of the Resque::Failure::Pagerduty.service_key to trigger the incident.

When there is no Resque::Failure::Pagerduty.service_key configured, and there is no pagerduty_service_key callback defined on the job class, then the failure backend will exit gracefully. This allows you to selectively enable Pagerduty notifications for some jobs without enabling them for all jobs.

Examples

Single Resque Failure Backend

Using only the Pagerduty failure backend:

require 'resque/failure/pagerduty'

Resque::Failure::Pagerduty.configure do |config|
  config.service_key = 'my_pagerduty_service_key'
end

Resque::Failure.backend = Resque::Failure::Pagerduty

Multiple Resque Failure Backends

Using both the Redis and Pagerduty failure backends:

require 'resque/failure/pagerduty'
require 'resque/failure/redis'
require 'resque/failure/multiple'

Resque::Failure::Pagerduty.configure do |config|
  config.service_key = 'my_pagerduty_service_key'
end

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

Contributing

  1. Fork the repository.
  2. Create a topic branch.
  3. bundle install
  4. rake spec
  5. Implement your feature or bug fix, including specs.
  6. Add, commit, and push your changes to your fork.
  7. Submit a pull request.

resque-pagerduty's People

Watchers

Nestor G Pestelos Jr avatar James Cloos avatar  avatar

Forkers

ramontayag

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.