Sha256: 4dc8f57a38163057cbea552e08935fe11e8d5abfd6770b596dd2514217e59608

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module SDK
    module Trace
      # A text annotation with a set of attributes and a timestamp.
      class Event
        EMPTY_ATTRIBUTES = {}.freeze

        private_constant :EMPTY_ATTRIBUTES

        # Returns the name of this event
        #
        # @return [String]
        attr_reader :name

        # Returns the frozen attributes for this event
        #
        # @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
        attr_reader :attributes

        # Returns the timestamp for this event
        #
        # @return [Time]
        attr_reader :timestamp

        # Returns a new immutable {Event}.
        #
        # @param [String] name The name of this event
        # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}]
        #   attributes A hash of attributes for this event. Attributes will be
        #   frozen during Event initialization.
        # @param [optional Time] timestamp The timestamp for this event.
        #   Defaults to Time.now.
        # @return [Event]
        def initialize(name:, attributes: nil, timestamp: nil)
          @name = name
          @attributes = attributes.freeze || EMPTY_ATTRIBUTES
          @timestamp = timestamp || Time.now
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opentelemetry-sdk-0.10.0 lib/opentelemetry/sdk/trace/event.rb
opentelemetry-sdk-0.9.0 lib/opentelemetry/sdk/trace/event.rb
opentelemetry-sdk-0.8.0 lib/opentelemetry/sdk/trace/event.rb
opentelemetry-sdk-0.7.0 lib/opentelemetry/sdk/trace/event.rb
opentelemetry-sdk-0.6.0 lib/opentelemetry/sdk/trace/event.rb