diff --git a/examples/support-agent/main.py b/examples/support-agent/main.py index 0d9e973..aba252a 100644 --- a/examples/support-agent/main.py +++ b/examples/support-agent/main.py @@ -61,11 +61,11 @@ def run_demo( ) order = client.get_order(DEFAULT_ORDER_ID) user = client.get_user(order.user_id) - active_sessions = client.get_metric("active_sessions", window="1h") + active_sessions = client.get_metric("active_sessions", window="now") response = ( f"Order {order.order_id} is {order.status}. " f"The customer is {user.user_id} with {user.total_orders} lifetime orders " - f"and {active_sessions.value} active sessions in the last hour." + f"and {active_sessions.value} active sessions right now." ) return { @@ -76,7 +76,7 @@ def run_demo( "status": order.status, "user_id": user.user_id, "user_total_orders": user.total_orders, - "active_sessions_1h": active_sessions.value, + "active_sessions_now": active_sessions.value, "response": response, "steps": [ "Fetched the live order entity", diff --git a/tests/e2e/test_agent_journeys.py b/tests/e2e/test_agent_journeys.py index 714e6e1..77bb268 100644 --- a/tests/e2e/test_agent_journeys.py +++ b/tests/e2e/test_agent_journeys.py @@ -20,7 +20,9 @@ async def test_support_agent_journey(base_url: str, support_api_key: str): user = await client.get_user(order.user_id) assert user.user_id == "USR-10001" - metric = await client.get_metric("active_sessions", window="1h") + # active_sessions is a point-in-time gauge — its only declared window is + # "now". (audit_30_06_26.md A1: /v1/metrics now rejects undeclared windows.) + metric = await client.get_metric("active_sessions", window="now") assert metric.value >= 0 diff --git a/tests/unit/test_agent_query_async.py b/tests/unit/test_agent_query_async.py index 8523f91..3eb46ba 100644 --- a/tests/unit/test_agent_query_async.py +++ b/tests/unit/test_agent_query_async.py @@ -111,7 +111,9 @@ async def test_get_metric_rejects_window_not_in_available_windows(): bad = await client.get("/v1/metrics/revenue?window=2h") good = await client.get("/v1/metrics/revenue?window=1h") bad_active = await client.get("/v1/metrics/active_sessions?window=24h") + good_active = await client.get("/v1/metrics/active_sessions?window=now") assert bad.status_code == 422 # 2h is not a declared window for revenue assert good.status_code == 200 assert bad_active.status_code == 422 # active_sessions only supports "now" + assert good_active.status_code == 200 # "now" is active_sessions' declared window