Class: Honeybadger::ContextManager Private
- Inherits:
-
Object
- Object
- Honeybadger::ContextManager
- 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
- .current ⇒ Object private
Instance Method Summary collapse
- #clear! ⇒ Object private
- #get_context ⇒ Object private
- #get_rack_env ⇒ Object private
- #get_request_id ⇒ Object private
-
#initialize ⇒ ContextManager
constructor
private
A new instance of ContextManager.
- #set_context(hash, &block) ⇒ Object private
- #set_rack_env(env) ⇒ Object private
- #set_request_id(request_id) ⇒ Object private
Methods included from Conversions
Constructor Details
#initialize ⇒ ContextManager
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.
12 13 14 15 |
# File 'lib/honeybadger/context_manager.rb', line 12 def initialize @mutex = Mutex.new _initialize end |
Class Method Details
.current ⇒ 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.
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.
17 18 19 |
# File 'lib/honeybadger/context_manager.rb', line 17 def clear! _initialize end |
#get_context ⇒ 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.
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_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.
60 61 62 |
# File 'lib/honeybadger/context_manager.rb', line 60 def get_rack_env @mutex.synchronize { @rack_env } end |
#get_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.
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.
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.
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.
64 65 66 |
# File 'lib/honeybadger/context_manager.rb', line 64 def set_request_id(request_id) @mutex.synchronize { @request_id = request_id } end |