Sha256: 1fdc38c9c5ff1e91a5695b305f733b60e7432f4d7a88005724a28c40c6d4694d

Contents?: true

Size: 645 Bytes

Versions: 47

Compression:

Stored size: 645 Bytes

Contents

# frozen_string_literal: true

module Labkit
  module Correlation
    # CorrelationId module provides access the Correlation-ID
    # of the current request
    module CorrelationId
      LOG_KEY = Labkit::Context::CORRELATION_ID_KEY

      class << self
        def use_id(correlation_id)
          Labkit::Context.with_context(LOG_KEY => correlation_id) do |context|
            yield(context.correlation_id)
          end
        end

        def current_id
          Labkit::Context.correlation_id
        end

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

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
gitlab-labkit-0.36.1 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.36.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.35.1 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.35.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.34.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.33.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.32.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.31.1 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.31.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.30.1 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.30.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.29.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.28.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.27.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.26.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.25.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.24.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.23.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.22.0 lib/labkit/correlation/correlation_id.rb
gitlab-labkit-0.21.3 lib/labkit/correlation/correlation_id.rb