Skip to content

Commit 153f703

Browse files
committed
More fetch_normalized_spans
1 parent 7581696 commit 153f703

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

Diff for: tests/test_tracing.py

+28-29
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ async def test_complex_async_tracing() -> None:
224224

225225

226226
def spans_with_setters():
227-
with trace(workflow_name="test", trace_id="123", group_id="456"):
227+
with trace(workflow_name="test", trace_id="trace_123", group_id="456"):
228228
with agent_span(name="agent_1") as span_a:
229229
span_a.span_data.name = "agent_2"
230230

@@ -242,34 +242,33 @@ def spans_with_setters():
242242
def test_spans_with_setters() -> None:
243243
spans_with_setters()
244244

245-
spans, traces = fetch_ordered_spans(), fetch_traces()
246-
assert len(spans) == 4
247-
assert len(traces) == 1
248-
249-
trace = traces[0]
250-
standard_trace_checks(trace, name_check="test")
251-
trace_id = trace.trace_id
252-
253-
# Check the spans
254-
first_span = spans[0]
255-
standard_span_checks(first_span, trace_id=trace_id, parent_id=None, span_type="agent")
256-
assert first_span.span_data.name == "agent_2"
257-
258-
second_span = spans[1]
259-
standard_span_checks(
260-
second_span, trace_id=trace_id, parent_id=first_span.span_id, span_type="function"
261-
)
262-
assert second_span.span_data.input == "i"
263-
assert second_span.span_data.output == "o"
264-
265-
third_span = spans[2]
266-
standard_span_checks(
267-
third_span, trace_id=trace_id, parent_id=first_span.span_id, span_type="generation"
268-
)
269-
270-
fourth_span = spans[3]
271-
standard_span_checks(
272-
fourth_span, trace_id=trace_id, parent_id=first_span.span_id, span_type="handoff"
245+
assert fetch_normalized_spans() == snapshot(
246+
[
247+
{
248+
"workflow_name": "test",
249+
"group_id": "456",
250+
"children": [
251+
{
252+
"type": "agent",
253+
"data": {"name": "agent_2"},
254+
"children": [
255+
{
256+
"type": "function",
257+
"data": {"name": "function_1", "input": "i", "output": "o"},
258+
},
259+
{
260+
"type": "generation",
261+
"data": {"input": [{"foo": "bar"}]},
262+
},
263+
{
264+
"type": "handoff",
265+
"data": {"from_agent": "agent_1", "to_agent": "agent_2"},
266+
},
267+
],
268+
}
269+
],
270+
}
271+
]
273272
)
274273

275274

0 commit comments

Comments
 (0)