lib/opentelemetry/sdk/trace/tracer_provider.rb in opentelemetry-sdk-1.0.1 vs lib/opentelemetry/sdk/trace/tracer_provider.rb in opentelemetry-sdk-1.0.2
- old
+ new
@@ -124,20 +124,28 @@
@span_processors = @span_processors.dup.push(span_processor)
end
end
# @api private
- def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, instrumentation_library) # rubocop:disable Metrics/MethodLength
+ def internal_create_span(name, kind, trace_id, parent_span_id, attributes, links, start_timestamp, parent_context, parent_span, instrumentation_library) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
+ parent_span_context = parent_span.context
+ if parent_span_context.valid?
+ parent_span_id = parent_span_context.span_id
+ trace_id = parent_span_context.trace_id
+ end
+ name ||= 'empty'
trace_id ||= @id_generator.generate_trace_id
+ kind ||= :internal
result = @sampler.should_sample?(trace_id: trace_id, parent_context: parent_context, links: links, name: name, kind: kind, attributes: attributes)
span_id = @id_generator.generate_span_id
if result.recording? && !@stopped
trace_flags = result.sampled? ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT
context = OpenTelemetry::Trace::SpanContext.new(trace_id: trace_id, span_id: span_id, trace_flags: trace_flags, tracestate: result.tracestate)
attributes = attributes&.merge(result.attributes) || result.attributes
Span.new(
context,
parent_context,
+ parent_span,
name,
kind,
parent_span_id,
@span_limits,
@span_processors,