Вернул просмотр логов в сингл режим

This commit is contained in:
2026-08-31 12:17:43 +03:00
parent d2f5a22501
commit d1dd9e3d14
14 changed files with 580 additions and 47 deletions
+27 -43
View File
@@ -80,8 +80,8 @@ def test_trace_endpoint_returns_html_by_default() -> None:
levels=("ERROR", "WARNING", "INFO"),
include_attrs_json=False,
response_format="html",
ancestor_depth=None,
view="tree",
ancestor_depth=0,
view="single",
),
)
]
@@ -333,13 +333,13 @@ def test_trace_endpoint_returns_html_page_with_related_links() -> None:
assert "--error: #ff817d;" in response.text
assert "--other: #ececec;" in response.text
assert 'font: 13px/1.1 "SFMono-Regular", monospace;' in response.text
assert '<div class="line">trace_id: <a href="/traces/trace-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=tree&amp;ancestor_depth=all">trace-1</a></div>' in response.text
assert '<div class="line">parent_id: <a href="/traces/parent-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=tree&amp;ancestor_depth=all">parent-1</a></div>' in response.text
assert '<div class="line">trace_id: <a href="/traces/trace-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=single">trace-1</a></div>' in response.text
assert '<div class="line">parent_id: <a href="/traces/parent-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=single">parent-1</a></div>' in response.text
assert '<div class="line">child_ids:</div>' in response.text
assert '<div class="line"> - <a href="/traces/child-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=tree&amp;ancestor_depth=all">child-1</a></div>' in response.text
assert '<div class="line"> - <a href="/traces/child-2?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=tree&amp;ancestor_depth=all">child-2</a></div>' in response.text
assert '<div class="line"> - <a href="/traces/child-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=single">child-1</a></div>' in response.text
assert '<div class="line"> - <a href="/traces/child-2?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=single">child-2</a></div>' in response.text
assert '<div class="line">==============================</div>' in response.text
assert '<div class="line">trace context: order_confirmation, <a href="/traces/trace-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=tree&amp;ancestor_depth=all">trace-1</a></div>' in response.text
assert '<div class="line">trace context: order_confirmation, <a href="/traces/trace-1?format=html&amp;levels=ERROR%2CWARNING%2CINFO&amp;attrs_json=true&amp;view=single">trace-1</a></div>' in response.text
assert '<div class="line" style="color: var(--step);">load_stocks</div>' in response.text
assert '<div class="line" style="color: var(--step);">filter_stocks</div>' in response.text
assert "loaded prices" in response.text
@@ -450,43 +450,17 @@ def test_trace_endpoint_preserves_ancestor_depth_in_html_links() -> None:
assert "parent warning" in response.text
def test_trace_endpoint_returns_full_tree_by_default() -> None:
def test_trace_endpoint_returns_single_view_by_default() -> None:
async def trace_provider(trace_id: str, request: TraceQueryRequest) -> TraceLogView:
assert trace_id == "child-1"
assert request.view == "tree"
assert request.ancestor_depth is None
assert request.view == "single"
assert request.ancestor_depth == 0
return TraceLogView(
trace_id="root-1",
parent_id=None,
alias="root",
child_ids=("parent-1",),
records=(_trace_record(row_id=1, level="INFO", message="root message"),),
descendants=(
TraceLogView(
trace_id="parent-1",
parent_id="root-1",
alias="parent",
child_ids=("child-1", "sibling-1"),
records=(_trace_record(row_id=2, level="WARNING", message="parent message"),),
descendants=(
TraceLogView(
trace_id="child-1",
parent_id="parent-1",
alias="child",
child_ids=(),
records=(_trace_record(row_id=3, level="ERROR", message="child message"),),
),
TraceLogView(
trace_id="sibling-1",
parent_id="parent-1",
alias="sibling",
child_ids=(),
records=(_trace_record(row_id=4, level="INFO", message="sibling message"),),
),
),
),
),
requested_trace_id="child-1",
trace_id="child-1",
parent_id="parent-1",
alias="child",
child_ids=("leaf-1",),
records=(_trace_record(row_id=3, level="ERROR", message="child message"),),
)
client = _build_client(trace_provider)
@@ -496,8 +470,18 @@ def test_trace_endpoint_returns_full_tree_by_default() -> None:
client.close()
assert response.status_code == 200
assert "requested_trace_id: child-1" in response.text
assert response.text.index("root message") < response.text.index("parent message") < response.text.index("child message") < response.text.index("sibling message")
assert response.text == (
"trace_id: child-1\n"
"parent_id: parent-1\n"
"child_ids:\n"
" - leaf-1\n"
"\n"
"==============================\n"
"trace context: child, child-1\n"
"\n"
"step: process\n"
"child message"
)
def test_trace_endpoint_supports_single_view_opt_in() -> None: