tracer.start_span()
not working with_parent
#1363
-
I'm able to get a trace exported with the following: single_span = @tracer.start_span("single")
puts single_span #<OpenTelemetry::SDK::Trace::Span:0x0000ffff9894ac30>
puts single_span.context #<OpenTelemetry::Trace::SpanContext:0x0000ffff9894aca8>
puts "single span trace id: #{single_span.context.hex_trace_id}" #single span trace id: 821fcac9cfc6299c453547828ab9f697
single_span.finish It doesn't show any error but no traces got exported with the following: new_span_context = OpenTelemetry::Trace::SpanContext.new(
trace_id: ["42020f5b57b799cd98bc793ac046fad8"].pack("H*"),
)
puts "new context valid: #{new_span_context.valid?}" # true
new_span = OpenTelemetry::Trace::Span.new(span_context: new_span_context)
context_with_remote_parent = OpenTelemetry::Trace.context_with_span(new_span)
parent_span = @tracer.start_span("parent", with_parent: context_with_remote_parent)
puts parent_span #<OpenTelemetry::Trace::Span:0x0000ffff9894b400>
puts parent_span.context #<OpenTelemetry::Trace::SpanContext:0x0000ffff9894b478>
puts "parent span trace id: #{parent_span.context.hex_trace_id}" #parent span trace id: 42020f5b57b799cd98bc793ac046fad8
parent_span.finish I've spent a few days reading through the code and experimenting, any help is greatly appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@ToolKami I believe this is more appropriate to be a discussion since I do not think this is a bug. |
Beta Was this translation helpful? Give feedback.
-
@ToolKami Based on the code snippets it does not look like you are setting a parent span ID or the Sampling flag. Without a parent span id you will not be able to properly link the child span and the sampling flag is "off" by default: |
Beta Was this translation helpful? Give feedback.
@ToolKami Based on the code snippets it does not look like you are setting a parent span ID or the Sampling flag.
Without a parent span id you will not be able to properly link the child span and the sampling flag is "off" by default:
https://github.com/open-telemetry/opentelemetry-ruby/blob/main/api/lib/opentelemetry/trace/span_context.rb#L27