Sha256: 9a48a2e15db0fd74061f5534b0a156090040cee315c72272b9678e60f063d2fb
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 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_ONLY, Decision::DROP, Decision::RECORD_AND_SAMPLE].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_SAMPLE end # Returns true if this span should record events, attributes, status, etc. # # @return [Boolean] recording decision def recording? @decision != Decision::DROP end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems