Giter Club home page Giter Club logo

resque-slack's Introduction

Resque Slack

A Resque plugin. Requires Resque >= 1.19 and a >= 1.9 Ruby (MRI, JRuby or Rubinius).

Post a notification in a Slack channel when one your jobs fails.

Installation

Add this line to your application's Gemfile:

gem 'resque-slack'

And then execute:

$ bundle

Or install it yourself as:

$ gem install resque-slack

Usage

Configure your channel, token and notification verbosity:

require 'resque/failure/slack'

Resque::Failure::Slack.configure do |config|
  config.channel = 'CHANNEL_ID'  # required
  config.token = 'TEAM_TOKEN'    # required
  config.level = verbosity_level # optional
end

Resque::Failure.backend = Resque::Failure::Slack

Level can be:

  • verbose: worker, payload, exception and full backtrace
  • compact: worker, payload and exception
  • minimal: worker and payload only

NB: Your team token is found here

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Build Status Code Climate

resque-slack's People

Contributors

bitdeli-chef avatar julienxx avatar kao avatar olleolleolle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

resque-slack's Issues

Compact does not include exception

Firstly, thank you for this gem and your work!

Testing verbose level :compact I discovered that the exception description is meant to be displayed in the slack message, unfortunately this is not the case. To test this I used the following script:

require 'resque/failure/slack'
Resque::Failure::Slack.configure do |config|
  config.channel = ''
  config.token = ''
  config.level = :compact
end
resque_slack = Resque::Failure::Slack.new(
  ArgumentError,
  'JobName',
  'high',
  {
    data: []
  }
)
resque_slack.text

# Returns
# "JobName failed processing high\nPayload:\n  {:data=>[]}\n\n"

Proposed Changes

Since msg_exception last line returns nil for level :compact, I suggest that return str is inserted at the end of the function to ensure both levels :verbose and :compact work as expected:

Before:

def msg_exception(backtrace)
  str = "Exception:\n#{exception}"
  str += "\n#{exception.backtrace.map { |l| '  ' + l }.join('\n')}" if backtrace
end

After

def msg_exception(backtrace)
  str = "Exception:\n#{exception}"
  str += "\n#{exception.backtrace.map { |l| '  ' + l }.join('\n')}" if backtrace
  return str
end

Re-running the script now returns the following:

# "JobName failed processing high\nPayload:\n  {:data=>[]}\nException:\nArgumentError\n"

Please let me know if you would like me to raise PR for these changes.

ruby - 2.5.1
rails - 5.2.2
resque - 1.27

Please add webhook support

Neat tool and we are going to try it out. Looks like we had to add full API permissions for chat:write to our Slack App. But now Slack supports (encourages?) webhooks for writing messages. That would be a great option to have if this gets updated at some point.

Uninitialized constant Resque::Failure::Slack::Notification

In the latest version resque complains
*** Received exception when reporting failure: #<NameError: uninitialized constant Resque::Failure::Slack::Notification>
It comes because resque/failure/notification isn't required anywhere except spec_helper.

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.