Skip to content

Commit

Permalink
fix: Prioritize trace level from current context
Browse files Browse the repository at this point in the history
Signed-off-by: Ferenc Géczi <ferenc.geczi@ibm.com>
  • Loading branch information
Ferenc- committed Jul 31, 2024
1 parent ccf0e09 commit eb5f7bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/instana/propagators/base_propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __determine_span_context(self, trace_id, span_id, level, synthetic, tracepar

return ctx

def __extract_instana_headers(self, dc):
def extract_instana_headers(self, dc):
"""
Search carrier for the *HEADER* keys and return the tracing key-values
Expand Down Expand Up @@ -283,7 +283,7 @@ def extract(self, carrier, disable_w3c_trace_context=False):
return None
headers = {k.lower(): v for k, v in headers.items()}

trace_id, span_id, level, synthetic = self.__extract_instana_headers(dc=headers)
trace_id, span_id, level, synthetic = self.extract_instana_headers(dc=headers)
if not disable_w3c_trace_context:
traceparent, tracestate = self.__extract_w3c_trace_context_headers(dc=headers)

Expand Down
4 changes: 4 additions & 0 deletions src/instana/propagators/http_propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def __init__(self):
def inject(self, span_context, carrier, disable_w3c_trace_context=False):
trace_id = span_context.trace_id
span_id = span_context.span_id
# Suppression `level` made in the child context or in the parent context
# has priority over any non-suppressed `level` setting
child_level = int(self.extract_instana_headers(carrier)[2] or "1")
span_context.level = min(child_level, span_context.level)
serializable_level = str(span_context.level)

if disable_w3c_trace_context:
Expand Down

0 comments on commit eb5f7bc

Please sign in to comment.