Sha256: 8bbaea9332bc3228c39b544b3aac113b6676b0c4f4aac683da585002469395f4

Contents?: true

Size: 524 Bytes

Versions: 1

Compression:

Stored size: 524 Bytes

Contents

# frozen_string_literal: true

# Copyright 2019 OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  # The Context module provides per-thread storage.
  module Context
    extend self

    def get(key)
      storage[key]
    end

    def with(key, value)
      store = storage
      previous = store[key]
      store[key] = value
      yield value
    ensure
      store[key] = previous
    end

    private

    def storage
      Thread.current[:__opentelemetry__] ||= {}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-api-0.2.0 lib/opentelemetry/context.rb