feat(observe): main.py 挂中间件 + lifespan 启停上报 worker
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -225,3 +225,10 @@ async def test_stop_flushes_remaining_and_closes_client(monkeypatch):
|
||||
|
||||
assert b'"n"' in posted["body"] # 关停时把剩余事件发了出去
|
||||
assert observe_worker._client is None # client 已关闭并置空
|
||||
|
||||
|
||||
def test_app_has_metrics_middleware():
|
||||
from app.main import app
|
||||
|
||||
names = [m.cls.__name__ for m in app.user_middleware]
|
||||
assert "RequestMetricsMiddleware" in names
|
||||
|
||||
Reference in New Issue
Block a user