mirror of
https://github.com/AstrBotDevs/AstrBot.git
synced 2026-11-23 14:37:10 +08:00
* feat: expand message tracing and redesign trace explorer * feat: add trace metadata chips and preserve response ownership * feat: show full-width tracing list with optional details * style: remove gray trace tab card * feat: unify trace toolbar controls and use Vuetify datatable * style: use native Vuetify trace table rows * fix: prevent trace platform header wrapping * feat: persist message traces in bounded SQLite storage * fix: expose trace settings and preserve long prompt attributes * docs: simplify trace storage setting hints * feat: add trace history cleanup and disk usage accounting * fix: finish event traces and fold Agent execution chains * feat: fold long trace messages and consolidate persona metadata * fix: hide redundant adapter event labels in traces * refactor: remove redundant persisted span metadata * feat: paginate trace history with Vuetify table controls * style: reduce trace table text size * style: increase trace table text to 13px * style: flatten trace status chips and narrow platform column * feat: show independent Agent and command trace types * feat: show cumulative Agent token usage in trace details * style: abbreviate trace token counts with k and M * style: reduce trace table header height * feat: show group and private chat trace types * fix: include month and day in trace timestamps * style: use system trace fonts and blue running status * style: separate trace origin and sender metadata rows * fix: trace successful proactive message tool deliveries * feat: show model persona and tool counts on Agent headings * style: prefix trace plugin chips with puzzle icons * style: add icons and spacing to Agent metadata chips * style: remove execution mode prefix from trace chips * refactor: centralize response tracing without source attribution * style: hide module metadata in trace details * refactor: omit redundant module metadata from plugin traces * refactor: remove obsolete module filtering from trace UI * feat: expose trace recording toggle in system settings * docs: simplify trace recording setting description * feat: retain traces only for command responses and Agent calls * fix: revert trace admission filtering and expand writer queue * refactor: adopt OpenTelemetry SDK and simplify trace tests * refactor: separate event and trace execution contexts * fix: include OpenTelemetry SDK in runtime requirements * refactor: dispatch session waiters in the core pipeline Preserve access and safety checks before waiter dispatch and limit built-in group context handlers to group messages. * test: remove trace dashboard tests * fix: recover orphaned traces and enforce minimum storage budget * fix: increase trace queue byte budgets and remove frame count limit
63 lines
2.1 KiB
Python
63 lines
2.1 KiB
Python
"""Regression coverage for bounded trace writer burst capacity."""
|
|
|
|
import json
|
|
import threading
|
|
import time
|
|
|
|
import pytest
|
|
|
|
from astrbot.core.utils.trace_store import MAX_FRAME_BYTES, QUEUE_BYTES, TraceStore
|
|
|
|
|
|
@pytest.mark.parametrize("body_bytes", [32, 1536 * 1024])
|
|
def test_trace_queue_limits_bytes_without_frame_count_cap(tmp_path, monkeypatch, body_bytes):
|
|
"""Admit over 1024 small frames while bounding large frames by 128 MiB.
|
|
|
|
Args:
|
|
tmp_path: Isolated database directory.
|
|
monkeypatch: Pytest patch manager.
|
|
body_bytes: Payload length used to exercise small bursts or byte capacity.
|
|
"""
|
|
release = threading.Event()
|
|
original_run = TraceStore._run
|
|
|
|
def delayed_run(self):
|
|
"""Hold the consumer until queue admission has been measured."""
|
|
release.wait(10)
|
|
original_run(self)
|
|
|
|
monkeypatch.setattr(TraceStore, "_run", delayed_run)
|
|
store = TraceStore(tmp_path / "traces.db", {})
|
|
now = str(time.time_ns())
|
|
packet = {
|
|
"trace": {
|
|
"trace_id": "a" * 32,
|
|
"root_span_id": "b" * 16,
|
|
"start_time_unix_nano": now,
|
|
"state": "completed",
|
|
"has_errors": False,
|
|
"has_models": True,
|
|
"has_plugins": False,
|
|
"attributes": {"astrbot.message_outline": "x" * body_bytes},
|
|
},
|
|
"time_unix_nano": now,
|
|
}
|
|
frame_bytes = len(json.dumps(packet, ensure_ascii=False, separators=(",", ":")).encode())
|
|
attempts = 1025 if body_bytes == 32 else QUEUE_BYTES // frame_bytes + 1
|
|
expected = min(attempts, QUEUE_BYTES // frame_bytes)
|
|
try:
|
|
assert QUEUE_BYTES == 128 * 1024 * 1024
|
|
assert MAX_FRAME_BYTES == 2 * 1024 * 1024
|
|
assert store.queue.maxsize == 0
|
|
accepted = sum(store.append(packet) for _ in range(attempts))
|
|
assert accepted == expected
|
|
assert store.queue.qsize() == expected
|
|
assert store._pending_bytes <= QUEUE_BYTES
|
|
assert store.dropped == attempts - expected
|
|
release.set()
|
|
assert store.flush(15)
|
|
assert store._pending_bytes == 0
|
|
finally:
|
|
release.set()
|
|
store.close()
|