Class: Honeybadger::ContextManager Private

Inherits:
Object
  • Object
show all
Includes:
Conversions
Defined in:
lib/honeybadger/context_manager.rb

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.

Constant Summary

Constants included from Conversions

Honeybadger::Conversions::MAX_CONTEXT_DEPTH

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Conversions

Context

Constructor Details

#initializeContextManager

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 ContextManager.

[View source]

12
13
14
15
# File 'lib/honeybadger/context_manager.rb', line 12

def initialize
  @mutex = Mutex.new
  _initialize
end

Class Method Details

.currentObject

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.

[View source]

8
9
10
# File 'lib/honeybadger/context_manager.rb', line 8

def self.current
  Thread.current[:__hb_context_manager] ||= new
end

Instance Method Details

#clear!Object

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.

[View source]

17
18
19
# File 'lib/honeybadger/context_manager.rb', line 17

def clear!
  _initialize
end

#get_contextObject

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.

[View source]

48
49
50
51
52
53
54
# File 'lib/honeybadger/context_manager.rb', line 48

def get_context
  @mutex.synchronize do
    return @global_context unless @local_context

    @global_context.merge(@local_context.inject({}, :merge))
  end
end

#get_rack_envObject

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.

[View source]

60
61
62
# File 'lib/honeybadger/context_manager.rb', line 60

def get_rack_env
  @mutex.synchronize { @rack_env }
end

#get_request_idObject

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.

[View source]

68
69
70
# File 'lib/honeybadger/context_manager.rb', line 68

def get_request_id
  @mutex.synchronize { @request_id }
end

#set_context(hash, &block) ⇒ Object

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.

[View source]

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/honeybadger/context_manager.rb', line 24

def set_context(hash, &block)
  local = block_given?
  @mutex.synchronize do
    @global_context ||= {}
    @local_context ||= []

    new_context = Context(hash)

    if local
      @local_context << new_context
    else
      @global_context.update(new_context)
    end
  end

  if local
    begin
      yield
    ensure
      @mutex.synchronize { @local_context&.pop }
    end
  end
end

#set_rack_env(env) ⇒ Object

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.

[View source]

56
57
58
# File 'lib/honeybadger/context_manager.rb', line 56

def set_rack_env(env)
  @mutex.synchronize { @rack_env = env }
end

#set_request_id(request_id) ⇒ Object

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.

[View source]

64
65
66
# File 'lib/honeybadger/context_manager.rb', line 64

def set_request_id(request_id)
  @mutex.synchronize { @request_id = request_id }
end