Sha256: 28245c505aca0ffd9d8197b18a3229ff1f14418c38af7fe0b54102c1c6137b56
Contents?: true
Size: 1.89 KB
Versions: 5
Compression:
Stored size: 1.89 KB
Contents
# frozen_string_literal: true # Copyright 2019 OpenTelemetry Authors # # SPDX-License-Identifier: Apache-2.0 module OpenTelemetry module SDK module Trace module Samplers # The Result class represents an arbitrary sampling result. It has # boolean values for the sampling decision and whether to record # events, and a collection of attributes to be attached to a sampled # root span. class Result EMPTY_HASH = {}.freeze DECISIONS = [Decision::RECORD, Decision::NOT_RECORD, Decision::RECORD_AND_SAMPLED].freeze private_constant(:EMPTY_HASH, :DECISIONS) # Returns a frozen hash of attributes to be attached span. # # @return [Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] attr_reader :attributes # Returns a new sampling result with the specified decision and # attributes. # # @param [Symbol] decision Whether or not a span should be sampled # and/or record events. # @param [optional Hash{String => String, Numeric, Boolean, Array<String, Numeric, Boolean>}] # attributes A frozen or freezable hash containing attributes to be # attached to the span. def initialize(decision:, attributes: nil) @decision = decision @attributes = attributes.freeze || EMPTY_HASH end # Returns true if this span should be sampled. # # @return [Boolean] sampling decision def sampled? @decision == Decision::RECORD_AND_SAMPLED end # Returns true if this span should record events, attributes, status, etc. # # @return [Boolean] recording decision def recording? @decision != Decision::NOT_RECORD end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems