Module: EzLogsAgent::Correlation
- Defined in:
- lib/ez_logs_agent/correlation.rb
Constant Summary collapse
- STORE_KEY =
:ez_logs_correlation_id
Class Method Summary collapse
-
.clear ⇒ void
Clear the current correlation ID.
-
.current ⇒ String?
Get the current correlation ID (or nil).
-
.current=(value) ⇒ String?
Set the current correlation ID.
-
.generate ⇒ String
Generate a new unique correlation ID Format: ezl_<timestamp_ms>_<random_hex_8>.
Class Method Details
.clear ⇒ void
This method returns an undefined value.
Clear the current correlation ID
36 37 38 |
# File 'lib/ez_logs_agent/correlation.rb', line 36 def self.clear RequestStore.store.delete(STORE_KEY) end |
.current ⇒ String?
Get the current correlation ID (or nil)
21 22 23 |
# File 'lib/ez_logs_agent/correlation.rb', line 21 def self.current RequestStore.store[STORE_KEY] end |
.current=(value) ⇒ String?
Set the current correlation ID
29 30 31 |
# File 'lib/ez_logs_agent/correlation.rb', line 29 def self.current=(value) RequestStore.store[STORE_KEY] = value end |
.generate ⇒ String
Generate a new unique correlation ID Format: ezl_<timestamp_ms>_<random_hex_8>
12 13 14 15 16 |
# File 'lib/ez_logs_agent/correlation.rb', line 12 def self.generate = (Time.now.to_f * 1000).to_i random_hex = SecureRandom.hex(4) # 8 chars "ezl_#{}_#{random_hex}" end |