Sha256: 33bdc0aaf395f32d6b39c2232c2a43600cf27cec65cc2326dffd0f40a833a9af

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require "forwardable"
require "securerandom"
require "honeycomb/span"
require "honeycomb/propagation"
require "honeycomb/rollup_fields"

module Honeycomb
  # Represents a Honeycomb trace, which groups spans together
  class Trace
    include PropagationParser
    include RollupFields
    extend Forwardable

    def_delegators :@root_span, :send

    attr_reader :id, :fields, :root_span

    def initialize(builder:, context:, serialized_trace: nil, **options)
      trace_id, parent_span_id, trace_fields, dataset =
        parse serialized_trace
      dataset && builder.dataset = dataset
      @id = trace_id || SecureRandom.uuid
      @fields = trace_fields || {}
      @root_span = Span.new(trace: self,
                            parent_id: parent_span_id,
                            is_root: true,
                            builder: builder,
                            context: context,
                            **options)
    end

    def add_field(key, value)
      @fields[key] = value
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
honeycomb-beeline-2.1.1 lib/honeycomb/trace.rb
honeycomb-beeline-2.1.0 lib/honeycomb/trace.rb
honeycomb-beeline-2.0.0 lib/honeycomb/trace.rb
honeycomb-beeline-1.3.0 lib/honeycomb/trace.rb
honeycomb-beeline-1.2.0 lib/honeycomb/trace.rb
honeycomb-beeline-1.1.1 lib/honeycomb/trace.rb
honeycomb-beeline-1.1.0 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.1 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.0 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.0.pre.beta4 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.0.pre.beta3 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.0.pre.beta2 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.0.pre.beta1 lib/honeycomb/trace.rb
honeycomb-beeline-1.0.0.pre.beta lib/honeycomb/trace.rb