Skip to content

Commit efd739b

Browse files
committed
fix: handle suppression
Signed-off-by: Varsha GS <varsha.gs@ibm.com>
1 parent 5bd7996 commit efd739b

4 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/instana/propagators/base_propagator.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ def __determine_span_context(
181181
correlation = True
182182

183183
(
184-
ctx_trace_id,
185-
ctx_span_id,
186184
ctx_level,
187185
ctx_synthetic,
188186
ctx_trace_parent,
@@ -192,9 +190,11 @@ def __determine_span_context(
192190
ctx_correlation_id,
193191
ctx_traceparent,
194192
ctx_tracestate,
195-
) = [None] * 11
193+
) = [None] * 9
196194

197195
ctx_level = self._get_ctx_level(level)
196+
ctx_trace_id = trace_id
197+
ctx_span_id = span_id
198198

199199
if (
200200
trace_id
@@ -204,8 +204,6 @@ def __determine_span_context(
204204
):
205205
# ctx.trace_id = trace_id[-16:] # only the last 16 chars
206206
# ctx.span_id = span_id[-16:] # only the last 16 chars
207-
ctx_trace_id = trace_id
208-
ctx_span_id = span_id
209207
ctx_synthetic = synthetic
210208

211209
# if len(trace_id) > 16:

src/instana/tracer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ def start_span(
120120
) -> InstanaSpan:
121121
parent_context = span_context if span_context else get_current_span().get_span_context()
122122

123-
if parent_context is not None and not isinstance(parent_context, SpanContext):
123+
if parent_context and not isinstance(parent_context, SpanContext):
124124
raise TypeError("parent_context must be an Instana SpanContext or None.")
125125

126-
if parent_context is not None and not parent_context.is_valid:
126+
if parent_context and not parent_context.is_valid and not parent_context.suppression:
127127
# We probably have an INVALID_SPAN_CONTEXT.
128128
parent_context = None
129129

@@ -213,7 +213,7 @@ def _add_stack(self, span: InstanaSpan, limit: Optional[int] = 30) -> None:
213213
def _create_span_context(self, parent_context: SpanContext) -> SpanContext:
214214
"""Creates a new SpanContext based on the given parent context."""
215215

216-
if parent_context is not None and parent_context.trace_id is not None:
216+
if parent_context and parent_context.is_valid:
217217
trace_id = parent_context.trace_id
218218
span_id = generate_id()
219219
trace_flags = parent_context.trace_flags

tests/frameworks/test_flask.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def test_get_request_with_query_params(self) -> None:
191191
# We should NOT have a path template for this route
192192
assert wsgi_span.data["http"]["path_tpl"] is None
193193

194-
@unittest.skip("Suppression is not yet handled")
195194
def test_get_request_with_suppression(self) -> None:
196195
headers = {'X-INSTANA-L':'0'}
197196
response = self.http.urlopen('GET', testenv["flask_server"] + '/', headers=headers)
@@ -213,7 +212,7 @@ def test_get_request_with_suppression(self) -> None:
213212
# Assert that there are no spans in the recorded list
214213
assert spans == []
215214

216-
@unittest.skip("Suppression is not yet handled")
215+
@unittest.skip("Handled when type of trace and span ids are modified to str")
217216
def test_get_request_with_suppression_and_w3c(self) -> None:
218217
headers = {
219218
'X-INSTANA-L':'0',
@@ -239,7 +238,6 @@ def test_get_request_with_suppression_and_w3c(self) -> None:
239238
# Assert that there are no spans in the recorded list
240239
assert spans == []
241240

242-
@unittest.skip("Synthetic requests are not yet handled")
243241
def test_synthetic_request(self) -> None:
244242
headers = {
245243
'X-INSTANA-SYNTHETIC': '1'

tests/frameworks/test_wsgi.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def test_get_request(self) -> None:
8686
assert wsgi_span.data["http"]["error"] is None
8787
assert wsgi_span.stack is None
8888

89-
@pytest.mark.skip("Suppression is not yet handled")
9089
def test_synthetic_request(self) -> None:
9190
headers = {
9291
'X-INSTANA-SYNTHETIC': '1'

0 commit comments

Comments
 (0)