Skip to content

Commit 38b5933

Browse files
.
1 parent a139626 commit 38b5933

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

tests/conftest.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,23 +476,36 @@ def maybe_monkeypatched_threading(request):
476476

477477
@pytest.fixture
478478
def render_span_tree():
479-
def inner(event):
480-
assert event["type"] == "transaction"
479+
def inner(spans, root_span=None):
480+
streamed_spans = False
481+
if root_span is None:
482+
streamed_spans = True
481483

482484
by_parent = {}
483-
for span in event["spans"]:
485+
print("spans are", spans)
486+
for span in spans:
487+
print(span)
488+
if "parent_span_id" not in span:
489+
root_span = span
490+
continue
491+
484492
by_parent.setdefault(span["parent_span_id"], []).append(span)
485493

486494
def render_span(span):
487-
yield "- op={}: description={}".format(
488-
json.dumps(span.get("op")), json.dumps(span.get("description"))
489-
)
495+
if streamed_spans:
496+
yield "- sentry.op={}: name={}".format(
497+
json.dumps(span["attributes"].get("sentry.op")),
498+
json.dumps(span["name"]),
499+
)
500+
else:
501+
yield "- op={}: description={}".format(
502+
json.dumps(span.get("op")), json.dumps(span.get("description"))
503+
)
504+
490505
for subspan in by_parent.get(span["span_id"]) or ():
491506
for line in render_span(subspan):
492507
yield " {}".format(line)
493508

494-
root_span = event["contexts"]["trace"]
495-
496509
return "\n".join(render_span(root_span))
497510

498511
return inner

tests/integrations/sqlalchemy/test_sqlalchemy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Address(Base):
6363
assert session.query(Person).first() == bob
6464

6565
if span_streaming:
66-
items = capture_items("event", "transaction", "span")
66+
items = capture_items("event")
6767
capture_message("hi")
6868
(event,) = (item.payload for item in items if item.type == "event")
6969
else:
@@ -1201,7 +1201,7 @@ def test_span_origin(
12011201
"sqlite:///:memory:", connect_args={"check_same_thread": False}
12021202
)
12031203
if span_streaming:
1204-
items = capture_items("span", "transaction")
1204+
items = capture_items("span")
12051205
with sentry_sdk.traces.start_span(name="custom parent"):
12061206
with engine.connect() as con:
12071207
con.execute(text("SELECT 0"))

0 commit comments

Comments
 (0)