Class: Airbrake::Rack::ContextFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake/rack/context_filter.rb

Overview

Adds context (URL, User-Agent, framework version, controller and more).

Since:

  • v5.7.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContextFilter

Returns a new instance of ContextFilter.

Since:

  • v5.7.0



12
13
14
# File 'lib/airbrake/rack/context_filter.rb', line 12

def initialize
  @weight = 99
end

Instance Attribute Details

#weightInteger (readonly)

Returns:

  • (Integer)

Since:

  • v5.7.0



10
11
12
# File 'lib/airbrake/rack/context_filter.rb', line 10

def weight
  @weight
end

Instance Method Details

#call(notice) ⇒ Object

See Also:

  • FilterChain#refine

Since:

  • v5.7.0



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/airbrake/rack/context_filter.rb', line 17

def call(notice)
  return unless (request = notice.stash[:rack_request])

  context = notice[:context]

  context[:url] = request.url
  context[:userAgent] = request.user_agent

  add_ip(context, request)
  add_framework_version(context)

  controller = request.env['action_controller.instance']
  return unless controller

  context[:component] = controller.controller_name
  context[:action] = controller.action_name
end