Skip to content

Commit df3f3af

Browse files
committed
.
1 parent ef9e640 commit df3f3af

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

tests/conftest.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class UnwrappedItem:
331331
def capture_items(monkeypatch):
332332
"""Capture envelope payload, unfurling individual items."""
333333

334-
def inner(types=None):
334+
def inner(*types):
335335
telemetry = []
336336
test_client = sentry_sdk.get_client()
337337
old_capture_envelope = test_client.transport.capture_envelope
@@ -1254,29 +1254,6 @@ def werkzeug_set_cookie(client, servername, key, value):
12541254
client.set_cookie(key, value)
12551255

12561256

1257-
def envelopes_to_spans(envelopes):
1258-
res: "list[dict[str, Any]]" = []
1259-
for envelope in envelopes:
1260-
for item in envelope.items:
1261-
if item.type == "span":
1262-
for span_json in item.payload.json["items"]:
1263-
span = {
1264-
"start_timestamp": span_json["start_timestamp"],
1265-
"end_timestamp": span_json.get("end_timestamp"),
1266-
"trace_id": span_json["trace_id"],
1267-
"span_id": span_json["span_id"],
1268-
"name": span_json["name"],
1269-
"status": span_json["status"],
1270-
"is_segment": span_json["is_segment"],
1271-
"parent_span_id": span_json.get("parent_span_id"),
1272-
"attributes": {
1273-
k: v["value"] for (k, v) in span_json["attributes"].items()
1274-
},
1275-
}
1276-
res.append(span)
1277-
return res
1278-
1279-
12801257
@contextmanager
12811258
def patch_start_tracing_child(
12821259
fake_transaction_is_none: bool = False,

tests/integrations/asgi/test_asgi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ async def test_capture_transaction(
186186

187187
async with TestClient(app) as client:
188188
if span_streaming:
189-
items = capture_items(["span"])
189+
items = capture_items("span")
190190
else:
191191
events = capture_events()
192192
await client.get("/some_url?somevalue=123")
@@ -256,7 +256,7 @@ async def test_capture_transaction_with_error(
256256
app = SentryAsgiMiddleware(asgi3_app_with_error)
257257

258258
if span_streaming:
259-
items = capture_items(["event", "span"])
259+
items = capture_items("event", "span")
260260
else:
261261
events = capture_events()
262262

tests/tracing/test_span_streaming.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,43 @@
33
import sys
44
import time
55
from unittest import mock
6+
from typing import Any
67

78
import pytest
89

910
import sentry_sdk
1011
from sentry_sdk.profiler.continuous_profiler import get_profiler_id
1112
from sentry_sdk.traces import NoOpStreamedSpan, SpanStatus, StreamedSpan
12-
from tests.conftest import envelopes_to_spans
1313

1414

1515
minimum_python_38 = pytest.mark.skipif(
1616
sys.version_info < (3, 8), reason="Asyncio tests need Python >= 3.8"
1717
)
1818

1919

20+
def envelopes_to_spans(envelopes):
21+
res: "list[dict[str, Any]]" = []
22+
for envelope in envelopes:
23+
for item in envelope.items:
24+
if item.type == "span":
25+
for span_json in item.payload.json["items"]:
26+
span = {
27+
"start_timestamp": span_json["start_timestamp"],
28+
"end_timestamp": span_json.get("end_timestamp"),
29+
"trace_id": span_json["trace_id"],
30+
"span_id": span_json["span_id"],
31+
"name": span_json["name"],
32+
"status": span_json["status"],
33+
"is_segment": span_json["is_segment"],
34+
"parent_span_id": span_json.get("parent_span_id"),
35+
"attributes": {
36+
k: v["value"] for (k, v) in span_json["attributes"].items()
37+
},
38+
}
39+
res.append(span)
40+
return res
41+
42+
2043
def test_start_span(sentry_init, capture_envelopes):
2144
sentry_init(
2245
traces_sample_rate=1.0,

0 commit comments

Comments
 (0)