Module: OpenCensus::Context
- Defined in:
- lib/opencensus/context.rb
Overview
The Context module provides per-thread storage.
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.
45 46 47 |
# File 'lib/opencensus/context.rb', line 45 def get key storage[key] end |
.reset! ⇒ Object
Clears all values from the context.
62 63 64 |
# File 'lib/opencensus/context.rb', line 62 def reset! Thread.current[THREAD_KEY] = {} end |
.set(key, value) ⇒ Object
Store a value in the context.
35 36 37 |
# File 'lib/opencensus/context.rb', line 35 def set key, value storage[key] = value end |
.unset(key) ⇒ Object?
Unsets a value from the context.
55 56 57 |
# File 'lib/opencensus/context.rb', line 55 def unset key storage.delete key end |