Sha256: 93a3ccfa8e328a6c3ce7f4b3ec8b3a9c37dd74f7d4f1e82cdecca050d5ce5022
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 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, Object>] 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, Object>] 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opentelemetry-sdk-0.2.0 | lib/opentelemetry/sdk/trace/samplers/result.rb |