Skip to content

Commit

Permalink
Expect 'sampled' header to be unicode already
Browse files Browse the repository at this point in the history
This was a bug. I have no idea why I did it that way. The string is
always unicode in Py2.7 and Py3.4+ from what I can tell. The
.decode(utf8) before my changes was probably an unnecessary no-op.

This should fix #278 by properly parsing the header.
  • Loading branch information
spladug committed May 13, 2019
1 parent e2789eb commit d75c146
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion baseplate/integration/pyramid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _start_server_span(self, request, name, trace_info=None):

def _get_trace_info(self, headers):
extracted_values = TraceInfo.extract_upstream_header_values(TRACE_HEADER_NAMES, headers)
sampled = bool(extracted_values.get("sampled") == b"1")
sampled = bool(extracted_values.get("sampled") == "1")
flags = extracted_values.get("flags", None)
return TraceInfo.from_upstream(
int(extracted_values["trace_id"]),
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/pyramid_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_trace_headers(self):
"X-Trace": "1234",
"X-Parent": "2345",
"X-Span": "3456",
"X-Sampled": b"1",
"X-Sampled": "1",
"X-Flags": "1",
})

Expand All @@ -185,7 +185,7 @@ def test_b3_trace_headers(self):
"X-B3-TraceId": "1234",
"X-B3-ParentSpanId": "2345",
"X-B3-SpanId": "3456",
"X-B3-Sampled": b"1",
"X-B3-Sampled": "1",
"X-B3-Flags": "1",
})

Expand Down

0 comments on commit d75c146

Please sign in to comment.