Skip to content
Open
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
1 change: 1 addition & 0 deletions .changelog/33.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Jaeger propagator no longer forces the DEBUG flag on inject; a normally-sampled span now propagates only the SAMPLED flag
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def inject(

# Non-recording spans do not have a parent
span_parent_id = span.parent.span_id if span.is_recording() and span.parent else 0
trace_flags = span_context.trace_flags
if trace_flags.sampled:
trace_flags |= self.DEBUG_FLAG
# Only propagate the SAMPLED flag. The DEBUG flag must not be set on
# inject for a normally-sampled span, since that would force downstream
# Jaeger components into a forced-keep decision.
trace_flags = trace.TraceFlags(span_context.trace_flags & trace.TraceFlags.SAMPLED)

# set span identity
setter.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ def test_sampled_flag_set(self):
sample_flag_value = int(new_carrier[FORMAT.TRACE_ID_KEY].split(":")[3]) & 0x01
self.assertEqual(1, sample_flag_value)

def test_debug_flag_set(self):
def test_debug_flag_not_set_for_sampled_span(self):
# Injecting a normally-sampled span must set only the SAMPLED bit and
# must never force the Jaeger DEBUG (forced-keep) flag.
old_carrier = {FORMAT.TRACE_ID_KEY: self.serialized_uber_trace_id}
_, new_carrier = get_context_new_carrier(old_carrier)
debug_flag_value = int(new_carrier[FORMAT.TRACE_ID_KEY].split(":")[3]) & FORMAT.DEBUG_FLAG
self.assertEqual(FORMAT.DEBUG_FLAG, debug_flag_value)
flags = int(new_carrier[FORMAT.TRACE_ID_KEY].split(":")[3])
self.assertEqual(1, flags & 0x01)
self.assertEqual(0, flags & FORMAT.DEBUG_FLAG)

def test_sample_debug_flags_unset(self):
uber_trace_id = jaeger._format_uber_trace_id( # pylint: disable=protected-access
Expand Down
Loading