lib/opentelemetry/sdk/trace/tracer.rb in opentelemetry-sdk-0.7.0 vs lib/opentelemetry/sdk/trace/tracer.rb in opentelemetry-sdk-0.8.0
- old
+ new
@@ -35,14 +35,17 @@
def start_span(name, with_parent: nil, attributes: nil, links: nil, start_timestamp: nil, kind: nil) # rubocop:disable Metrics/AbcSize
name ||= 'empty'
with_parent ||= Context.current
- parent_span_context = current_span(with_parent).context
- parent_span_context = nil unless parent_span_context.valid?
- parent_span_id = parent_span_context&.span_id
- tracestate = parent_span_context&.tracestate
- trace_id = parent_span_context&.trace_id
+ parent_span_context = OpenTelemetry::Trace.current_span(with_parent).context
+ if parent_span_context.valid?
+ parent_span_id = parent_span_context.span_id
+ tracestate = parent_span_context.tracestate
+ trace_id = parent_span_context.trace_id
+ else
+ parent_span_context = nil
+ end
trace_id ||= OpenTelemetry::Trace.generate_trace_id
sampler = tracer_provider.active_trace_config.sampler
result = sampler.should_sample?(trace_id: trace_id, parent_context: parent_span_context, links: links, name: name, kind: kind, attributes: attributes)
internal_create_span(result, name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, tracestate, with_parent)
end