Module: Labkit::Correlation::CorrelationId

Defined in:
lib/labkit/correlation/correlation_id.rb

Overview

CorrelationId module provides access the Correlation-ID of the current request

Class Method Summary collapse

Class Method Details

.current_idObject



17
18
19
# File 'lib/labkit/correlation/correlation_id.rb', line 17

def current_id
  Labkit::Context.correlation_id
end

.current_or_new_idObject



21
22
23
# File 'lib/labkit/correlation/correlation_id.rb', line 21

def current_or_new_id
  current_id || Labkit::Context.push.correlation_id
end

.use_id(correlation_id) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/labkit/correlation/correlation_id.rb', line 9

def use_id(correlation_id)
  Labkit::Context.with_context(
    Labkit::Fields::CORRELATION_ID => correlation_id
  ) do |context|
    yield(context.correlation_id)
  end
end