Class: Rack::JiraExceptionCollector

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/jira_exception_collector.rb,
lib/rack/jira_exception_collector_version.rb

Defined Under Namespace

Classes: BacktraceLine, Error

Constant Summary collapse

FILTER_REPLACEMENT =
"[FILTERED]"
VERSION =
"0.8.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, collector_url = nil) {|_self| ... } ⇒ JiraExceptionCollector

Returns a new instance of JiraExceptionCollector.

Yields:

  • (_self)

Yield Parameters:

Raises:



18
19
20
21
22
23
24
25
26
27
# File 'lib/rack/jira_exception_collector.rb', line 18

def initialize(app, collector_url = nil)
  @app                 = app
  @collector_url       = collector_url
  @report_under        = %w(production staging)
  @rack_environment    = "RACK_ENV"
  @environment_filters = %w(AWS_ACCESS_KEY AWS_SECRET_ACCESS_KEY AWS_ACCOUNT SSH_AUTH_SOCK)
  @failsafe            = $stderr
  yield self if block_given?
  raise(Error, "You need to provide a collector URL") unless @collector_url
end

Instance Attribute Details

#collector_urlObject

Returns the value of attribute collector_url.



15
16
17
# File 'lib/rack/jira_exception_collector.rb', line 15

def collector_url
  @collector_url
end

#environment_filtersObject

Returns the value of attribute environment_filters.



15
16
17
# File 'lib/rack/jira_exception_collector.rb', line 15

def environment_filters
  @environment_filters
end

#errorObject

Returns the value of attribute error.



15
16
17
# File 'lib/rack/jira_exception_collector.rb', line 15

def error
  @error
end

#failsafeObject

Returns the value of attribute failsafe.



15
16
17
# File 'lib/rack/jira_exception_collector.rb', line 15

def failsafe
  @failsafe
end

#rack_environmentObject

Returns the value of attribute rack_environment.



15
16
17
# File 'lib/rack/jira_exception_collector.rb', line 15

def rack_environment
  @rack_environment
end

#report_underObject

Returns the value of attribute report_under.



15
16
17
# File 'lib/rack/jira_exception_collector.rb', line 15

def report_under
  @report_under
end

Instance Method Details

#call(env) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rack/jira_exception_collector.rb', line 29

def call(env)
  status, headers, body =
    begin
      @app.call(env)
    rescue StandardError, LoadError, SyntaxError => boom
      notified = send_exception boom, env
      raise
    end
  send_exception env['rack.exception'], env if env['rack.exception']
  [status, headers, body]
end

#environment_filter_keysObject



41
42
43
# File 'lib/rack/jira_exception_collector.rb', line 41

def environment_filter_keys
  @environment_filters.flatten
end

#environment_filter_regexpsObject



45
46
47
48
49
# File 'lib/rack/jira_exception_collector.rb', line 45

def environment_filter_regexps
  environment_filter_keys.map do |key|
    "^#{Regexp.escape(wrapped_key_for(key))}$"
  end
end