Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/instana/trace/span_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def span_id_header
def trace_parent_header
trace = (@baggage[:external_trace_id] || trace_id_header).rjust(32, '0')
parent = span_id_header.rjust(16, '0')
flags = @level == 1 ? "01" : "00"
flags = @level == 1 ? "03" : "02"

"00-#{trace}-#{parent}-#{flags}"
end
Expand Down
2 changes: 1 addition & 1 deletion test/instrumentation/rack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_basic_get
assert last_response.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"

# W3C Trace Context
assert_equal "00-#{rack_span[:t].rjust(32, '0')}-#{rack_span[:s]}-01", last_response.headers["Traceparent"]
assert_equal "00-#{rack_span[:t].rjust(32, '0')}-#{rack_span[:s]}-03", last_response.headers["Traceparent"]
assert_equal "in=#{rack_span[:t]};#{rack_span[:s]}", last_response.headers["Tracestate"]

assert rack_span.key?(:data)
Expand Down
8 changes: 7 additions & 1 deletion test/trace/span_context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ def test_invalid

def test_flags_level_zero
subject = Instana::SpanContext.new(trace_id: 'trace', span_id: 'span', level: 0, baggage: {external_state: 'cn=test'})
assert_equal '00-000000000000000000000000000trace-000000000000span-00', subject.trace_parent_header
assert_equal '00-000000000000000000000000000trace-000000000000span-02', subject.trace_parent_header
assert_equal 'cn=test', subject.trace_state_header
end

def test_flags_level_zero_with_random_flag
subject = Instana::SpanContext.new(trace_id: 'trace', span_id: 'span', level: 1, baggage: {external_state: 'cn=test'})
assert_equal '00-000000000000000000000000000trace-000000000000span-03', subject.trace_parent_header
assert_equal 'in=trace;span,cn=test', subject.trace_state_header
end
end
Loading