Last active
August 29, 2015 14:21
-
-
Save 1syo/50ecfd857fc20a14d559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -n "$DEBUG" ]; then | |
exec coffee --nodejs --debug node_modules/.bin/hubot "$@" | |
else | |
exec node_modules/.bin/hubot -a slack "$@" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# spike | |
HUBOT_AIRBRAKE_KEY = process.env.HUBOT_AIRBRAKE_KEY | |
_ = require 'underscore' | |
class Notice | |
constructor: (body) -> | |
@json = JSON.parse(body) | |
general: -> | |
backtrace: -> | |
@json.notice.errors[0].backtrace | |
context: -> | |
@json.notice.context | |
params: -> | |
@json.notice.context | |
session: -> | |
@json.notice.session | |
env: -> | |
@json.notice.envorionment | |
module.exports = (robot) -> | |
robot.router.post "/hubot/airbrake/:room", (req, res) -> | |
data = | |
project_id: req.body.error.project.id | |
notice_id: req.body.error.last_notice.id | |
group_id: req.body.error.id | |
robot.brain.set('spike', data) | |
res.end "Done" | |
robot.respond /a(?:irbrake)? last( \| (general|backtrace|params|env|session|context))?/i, (msg) -> | |
filter = msg.match[2] | |
data = robot.brain.get('spike') | |
host = "https://airbrake.io" | |
path = "/api/v3" | |
path += "/projects/#{data.project_id}" | |
path += "/groups/#{data.group_id}" | |
path += "/notices/#{data.notice_id}" | |
msg.http(host) | |
.path(path) | |
.query(key: HUBOT_AIRBRAKE_KEY) | |
.get() (err, res, body) -> | |
if err | |
msg.send err | |
else | |
msg.send body | |
robot.respond /a(?:irbrake)? projects/i, (msg) -> | |
host = "https://airbrake.io" | |
path = "/api/v3/projects" | |
msg.http(host) | |
.path(path) | |
.query(key: HUBOT_AIRBRAKE_KEY) | |
.get() (err, res, body) -> | |
if err | |
msg.send err | |
else | |
msg.send body | |
robot.respond /a(?:irbrake)? errors ([^\s]+)( \| (.+))?/i, (msg) -> | |
project_id = msg.match[1] | |
envorionment = msg.match[3] | |
host = "https://airbrake.io" | |
path = "/api/v3/projects/#{project_id}/groups" | |
query = {} | |
query = {environment: envorionment} if envorionment | |
msg.http(host) | |
.path(path) | |
.query(key: HUBOT_AIRBRAKE_KEY) | |
.query(query) | |
.get() (err, res, body) -> | |
if err | |
msg.send err | |
else | |
msg.send body | |
# | |
# robot.respond /a(?:irbrake)? notice ([^\s]+)( \| (general|backtrace|params|env|session|context))?/i, (msg) -> | |
# # url = "https://airbrake.io/api/v3/projects/#{airbrake.project_id}/groups/#{airbrake.group_id}?key=#{HUBOT_AIRBRAKE_KEY}" | |
# msg.send msg.match[1], msg.match[3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/bash | |
JSON=`cat<<__JSON__ | |
{ | |
"error":{ | |
"id":"1185011750204075649", | |
"error_message":"RuntimeError: You threw an exception for testing", | |
"error_class":"RuntimeError", | |
"file":"[PROJECT_ROOT]/app/controllers/pages_controller.rb", | |
"line_number":35, | |
"project":{ | |
"id":"96574", | |
"name":"Airbrake" | |
}, | |
"last_notice":{ | |
"id":"1415229872486476729", | |
"request_method":null, | |
"request_url":"http://airbrake.io:445/pages/exception_test", | |
"backtrace":[ | |
"[PROJECT_ROOT]/app/controllers/pages_controller.rb:35:in 'exception_tester'", | |
"[PROJECT_ROOT]/app/middleware/conditional_heroku_nav.rb:19:in '_call'", | |
"[PROJECT_ROOT]/app/middleware/conditional_heroku_nav.rb:11:in 'call_without_newrelic'", | |
"[PROJECT_ROOT]/app/middleware/notifier_api.rb:33:in '_call'", | |
"[PROJECT_ROOT]/app/middleware/notifier_api.rb:23:in 'call_without_newrelic'", | |
"[PROJECT_ROOT]/app/middleware/notifier_post_body_translator.rb:8:in 'call'", | |
"[PROJECT_ROOT]/app/middleware/xml_request_truncator.rb:34:in '_call'", | |
"[PROJECT_ROOT]/app/middleware/xml_request_truncator.rb:23:in 'call_without_newrelic'", | |
"[PROJECT_ROOT]/app/middleware/deprecated_notifier_api.rb:33:in '_call'", | |
"[PROJECT_ROOT]/app/middleware/deprecated_notifier_api.rb:23:in 'call_without_newrelic'", | |
"[PROJECT_ROOT]/app/middleware/notifier_api_request_verification.rb:33:in '_call'", | |
"[PROJECT_ROOT]/app/middleware/notifier_api_request_verification.rb:23:in 'call_without_newrelic'" | |
] | |
}, | |
"environment":"production", | |
"first_occurred_at":"2012-02-23T22:03:03Z", | |
"last_occurred_at":"2012-03-21T08:37:15Z", | |
"times_occurred":118} | |
} | |
__JSON__` | |
echo "$JSON" | |
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "$JSON" "http://127.0.0.1:8080/hubot/airbrake/a" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment