Module: OpenCensus::Context
- Defined in:
- lib/opencensus/context.rb
Overview
The Context module provides per-thread storage.
Constant Summary collapse
- THREAD_KEY =
Thread local storage key under which all OpenCensus context data is stored.
:__opencensus_context__
Class Method Summary collapse
-
.get(key) ⇒ Object?
Return a value from the context.
-
.reset! ⇒ Object
Clears all values from the context.
-
.set(key, value) ⇒ Object
Store a value in the context.
-
.unset(key) ⇒ Object?
Unsets a value from the context.
Class Method Details
.get(key) ⇒ Object?
Return a value from the context. Returns nil if no value is set.
44 45 46 |
# File 'lib/opencensus/context.rb', line 44 def get key storage[key] end |
.reset! ⇒ Object
Clears all values from the context.
61 62 63 |
# File 'lib/opencensus/context.rb', line 61 def reset! Thread.current[THREAD_KEY] = {} end |
.set(key, value) ⇒ Object
Store a value in the context.
34 35 36 |
# File 'lib/opencensus/context.rb', line 34 def set key, value storage[key] = value end |
.unset(key) ⇒ Object?
Unsets a value from the context.
54 55 56 |
# File 'lib/opencensus/context.rb', line 54 def unset key storage.delete key end |