lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-0.6.0 vs lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-0.7.0

- old
+ new

@@ -14,10 +14,14 @@ # Instrumentation should use the API provided by {OpenTelemetry::Trace::Span} # and should consider {Span} to be write-only. # # rubocop:disable Metrics/ClassLength class Span < OpenTelemetry::Trace::Span + DEFAULT_STATUS = OpenTelemetry::Trace::Status.new(OpenTelemetry::Trace::Status::UNSET) + + private_constant(:DEFAULT_STATUS) + # The following readers are intended for the use of SpanProcessors and # should not be considered part of the public interface for instrumentation. attr_reader :name, :status, :kind, :parent_span_id, :start_timestamp, :end_timestamp, :links, :resource, :instrumentation_library # Return a frozen copy of the current attributes. This is intended for @@ -217,11 +221,10 @@ SpanData.new( @name, @kind, @status, @parent_span_id, - @child_count, @total_recorded_attributes, @total_recorded_events, @total_recorded_links, @start_timestamp, @end_timestamp, @@ -236,32 +239,31 @@ context.tracestate ) end # @api private - def initialize(context, name, kind, parent_span_id, trace_config, span_processor, attributes, links, start_timestamp, resource, instrumentation_library) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength + def initialize(context, parent_context, name, kind, parent_span_id, trace_config, span_processor, attributes, links, start_timestamp, resource, instrumentation_library) # rubocop:disable Metrics/AbcSize super(span_context: context) @mutex = Mutex.new @name = name @kind = kind @parent_span_id = parent_span_id.freeze || OpenTelemetry::Trace::INVALID_SPAN_ID @trace_config = trace_config @span_processor = span_processor @resource = resource @instrumentation_library = instrumentation_library @ended = false - @status = nil - @child_count = 0 + @status = DEFAULT_STATUS @total_recorded_events = 0 @total_recorded_links = links&.size || 0 @total_recorded_attributes = attributes&.size || 0 @start_timestamp = start_timestamp @end_timestamp = nil @attributes = attributes.nil? ? nil : Hash[attributes] # We need a mutable copy of attributes. trim_span_attributes(@attributes) @events = nil @links = trim_links(links, trace_config.max_links_count, trace_config.max_attributes_per_link) - @span_processor.on_start(self) + @span_processor.on_start(self, parent_context) end # TODO: Java implementation overrides finalize to log if a span isn't finished. private