Skip to content

Commit

Permalink
Improve stdout for span link tests (#3659)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne authored Dec 11, 2024
1 parent 36be84b commit d297019
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/test_distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
from utils import weblog, interfaces, scenarios, features, bug, context
from utils.parametric.spec.trace import SAMPLING_PRIORITY_KEY, ORIGIN
from utils.tools import logger


@scenarios.trace_propagation_style_w3c
Expand Down Expand Up @@ -213,16 +214,19 @@ def setup_span_links_flags_from_conflicting_contexts(self):
self.req = weblog.get("/make_distant_call", params={"url": "http://weblog:7777"}, headers=extract_headers)

def test_span_links_flags_from_conflicting_contexts(self):
trace = [
spans = [
span
for _, _, span in interfaces.library.get_spans(self.req, full_trace=True)
if _retrieve_span_links(span) is not None
and span["trace_id"] == 2
and span["parent_id"] == 987654321 # Only fetch the trace that is related to the header extractions
]

assert len(trace) == 1
span = trace[0]
if len(spans) != 1:
logger.error(json.dumps(spans, indent=2))
raise ValueError(f"Expected 1 span, got {len(spans)}")

span = spans[0]
span_links = _retrieve_span_links(span)
assert len(span_links) == 2
link1 = span_links[0]
Expand Down Expand Up @@ -255,16 +259,19 @@ def setup_span_links_omit_tracestate_from_conflicting_contexts(self):
self.req = weblog.get("/make_distant_call", params={"url": "http://weblog:7777"}, headers=extract_headers)

def test_span_links_omit_tracestate_from_conflicting_contexts(self):
trace = [
spans = [
span
for _, _, span in interfaces.library.get_spans(self.req, full_trace=True)
if _retrieve_span_links(span) is not None
and span["trace_id"] == 2
and span["parent_id"] == 987654321 # Only fetch the trace that is related to the header extractions
]

assert len(trace) == 1
span = trace[0]
if len(spans) != 1:
logger.error(json.dumps(spans, indent=2))
raise ValueError(f"Expected 1 span, got {len(spans)}")

span = spans[0]
links = _retrieve_span_links(span)
assert len(links) == 1
link1 = links[0]
Expand Down

0 comments on commit d297019

Please sign in to comment.