Class: Airbrake::Filters::ContextFilter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/filters/context_filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Adds user context to the notice object. Clears the context after it’s attached.

Since:

  • v2.9.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContextFilter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ContextFilter.

Since:

  • v2.9.0



12
13
14
15
# File 'lib/airbrake-ruby/filters/context_filter.rb', line 12

def initialize
  @weight = 119
  @mutex = Mutex.new
end

Instance Attribute Details

#weightInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)

Since:

  • v2.9.0



10
11
12
# File 'lib/airbrake-ruby/filters/context_filter.rb', line 10

def weight
  @weight
end

Instance Method Details

#call(notice) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

This is a mandatory method required by any filter integrated with FilterChain.

Parameters:

  • notice (Notice)

    the notice to be filtered

See Also:

Since:

  • v2.9.0



18
19
20
21
22
23
24
25
# File 'lib/airbrake-ruby/filters/context_filter.rb', line 18

def call(notice)
  @mutex.synchronize do
    return if Airbrake::Context.current.empty?

    notice[:params][:airbrake_context] = Airbrake::Context.current.to_h
    Airbrake::Context.current.clear
  end
end