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
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Ferenc- , according to PEP 333, response_headers are a list of tuples. I tested with wsgi frameworks bottle and cherrypy and both of them produce errors with our existing code on the master branch.

2024-08-07 18:38:40,399: 43705 DEBUG instana: extract error:
Traceback (most recent call last):
  File "/Users/varsha/Documents/GitHub/instana-repos/tracer-repos/python-sensor/src/instana/propagators/base_propagator.py", line 221, in extract_instana_headers
    trace_id = dc.get(self.LC_HEADER_KEY_T) or dc.get(self.ALT_LC_HEADER_KEY_T) or dc.get(
AttributeError: 'list' object has no attribute 'get'
# bottle
<class 'list'> [('Content-Length', '12'), ('Content-Type', 'text/html; charset=UTF-8')]
# cherrypy
<class 'list'> [('Content-Type', 'text/html;charset=utf-8'), ('Server', 'CherryPy/18.10.0'), ('Date', 'Wed, 07 Aug 2024 13:08:40 GMT'), ('Content-Length', '11')]

span_context.level = min(child_level, span_context.level)
serializable_level = str(span_context.level)

if disable_w3c_trace_context:
Expand Down