module Croket
Created on 2015-04-08
@author: Nikolay Moskvin <moskvin@sibext.com>
Created on 2015-04-08
@author: Nikolay Moskvin <moskvin@sibext.com>
Created on 2015-04-08
@author: Nikolay Moskvin <moskvin@sibext.com>
Created on 2015-04-08
@author: Nikolay Moskvin <moskvin@sibext.com>
Created on 2015-04-08
@author: Nikolay Moskvin <moskvin@sibext.com>
Created on 2015-04-08
@author: Nikolay Moskvin <moskvin@sibext.com>
Constants
- VERSION
Public Class Methods
configuration()
click to toggle source
# File lib/croket.rb, line 22 def configuration @configuration ||= Configuration.new end
configure(silent = false) { |configuration| ... }
click to toggle source
# File lib/croket.rb, line 18 def configure silent = false yield configuration end
notify(exception, opts = {})
click to toggle source
# File lib/croket.rb, line 26 def notify exception, opts = {} l = configuration.logger l.debug "[CROKET] notify about '#{exception}' #{opts['rack.errors']}" if configuration.environment_blacklist.include? configuration.environment.to_sym l.debug "[CROKET] notification was disabled for '#{configuration.environment}'" return end controller = opts['action_controller.instance'] request = ::Rack::Request.new(opts) params = request.env['action_dispatch.request.parameters'] version = "Rails/#{::Rails.version}" if defined?(::Rails) begin r = RestClient::Request.execute url: "http://#{configuration.host}/v1/issues.json", method: :post, payload: { issue: { description: "#{exception}\n#{generate_description(request, controller, params, exception)}", category: 'crash', package: configuration.package, environment: configuration.environment, version: version } }, headers: {'Authorization' => "Token token=#{configuration.api_key}"}, content_type: :json, accept: :json r = JSON.parse r l.debug "[CROKET] id: #{r['issue']['id']}, number: #{r['issue']['tracker_number']}, dup: #{r['issue']['duplication']}" rescue RestClient::RequestFailed => e l.error "Request to http://#{configuration.host}/v1/issues.json was failed:" + e.message end end
Private Class Methods
generate_description(request, controller, params, exception)
click to toggle source
# File lib/croket.rb, line 57 def generate_description request, controller, params, exception out = li('Url', request.url) if controller out += li('Controller', controller.controller_name) out += li('Action', controller.action_name) end out += li('Params', params) out += li('Error', exception.backtrace.first) out end
li(key, value)
click to toggle source
# File lib/croket.rb, line 68 def li key, value "* *#{key}*: #{value}\n" end