lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-1.3.1 vs lib/opentelemetry/sdk/trace/span.rb in opentelemetry-sdk-1.3.2
- old
+ new
@@ -280,11 +280,11 @@
context.tracestate
)
end
# @api private
- def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_scope) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
+ def initialize(context, parent_context, parent_span, name, kind, parent_span_id, span_limits, span_processors, attributes, links, start_timestamp, resource, instrumentation_scope) # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
super(span_context: context)
@mutex = Mutex.new
@name = name
@kind = kind
@parent_span_id = parent_span_id.freeze || OpenTelemetry::Trace::INVALID_SPAN_ID
@@ -295,11 +295,11 @@
@ended = false
@status = DEFAULT_STATUS
@total_recorded_events = 0
@total_recorded_links = links&.size || 0
@total_recorded_attributes = attributes&.size || 0
- @attributes = attributes.nil? ? nil : Hash[attributes] # We need a mutable copy of attributes.
+ @attributes = attributes
trim_span_attributes(@attributes)
@events = nil
@links = trim_links(links, span_limits.link_count_limit, span_limits.link_attribute_count_limit)
# Times are hard. Whenever an explicit timestamp is provided
@@ -315,11 +315,11 @@
# internally (and by child spans) to compute other timestamps.
# The last is the start timestamp actually recorded in the
# SpanData.
@monotonic_start_timestamp = monotonic_now
@realtime_start_timestamp = if parent_span.recording?
- relative_realtime(parent_span.realtime_start_timestamp, parent_span.monotonic_start_timestamp)
+ relative_realtime(parent_span.realtime_start_timestamp, parent_span.monotonic_start_timestamp, @monotonic_start_timestamp)
else
realtime_now
end
@start_timestamp = if start_timestamp
time_in_nanoseconds(start_timestamp)
@@ -417,18 +417,18 @@
end
def relative_timestamp(timestamp)
return time_in_nanoseconds(timestamp) unless timestamp.nil?
- relative_realtime(realtime_start_timestamp, monotonic_start_timestamp)
+ relative_realtime(realtime_start_timestamp, monotonic_start_timestamp, monotonic_now)
end
def time_in_nanoseconds(timestamp)
(timestamp.to_r * 1_000_000_000).to_i
end
- def relative_realtime(realtime_base, monotonic_base)
- realtime_base + (monotonic_now - monotonic_base)
+ def relative_realtime(realtime_base, monotonic_base, now)
+ realtime_base + (now - monotonic_base)
end
def realtime_now
Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
end