Repository navigation
fix: retain session start in metrics reports #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
25563bb
5d96200
dc3bd25
7fa5a10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -741,10 +741,11 @@ async def test_error_event_increments_total_failed(self, tmp_path): | |
| async def test_session_started_stores_timestamp(self, tmp_path): | ||
| loop = asyncio.get_event_loop() | ||
| with ManagedZMQContext.scoped(socket_dir=str(tmp_path)) as ctx: | ||
| agg, _, _ = make_aggregator(ctx, loop, "agg_started_ts") | ||
| agg, _, publisher = make_aggregator(ctx, loop, "agg_started_ts") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After rebasing onto agg, _, publisher = make_aggregator(
ctx, loop, "agg_started_ts", token_count_source=DEFAULT_SOURCE
) |
||
| try: | ||
| await agg.process([session_event(SessionEventType.STARTED, ts=42)]) | ||
| assert agg._table.session_started_ns == 42 | ||
| assert publisher.start.call_args.kwargs["session_started_ns"] == 42 | ||
| finally: | ||
| agg.close() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,6 +383,19 @@ def test_complete_flag_false_when_state_live(self): | |
|
|
||
| @pytest.mark.unit | ||
| class TestReportDisplayAndSerialize: | ||
| @pytest.mark.parametrize( | ||
| "start", [{}, {"session_started_ns": None}, {"session_started_ns": 42}] | ||
| ) | ||
| def test_start_time_from_snapshot(self, start): | ||
| snap = snapshot_to_dict( | ||
| _make_registry().build_snapshot( | ||
| state=SessionState.COMPLETE, n_pending_tasks=0 | ||
| ) | ||
| ) | ||
| snap.update(start) | ||
| report = Report.from_snapshot(snap) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After rebasing onto #552 made report = Report.from_snapshot(snap, token_count_source=DEFAULT_SOURCE)Verified locally: passes with this change. |
||
| assert report.test_started_at == (start.get("session_started_ns") or 0) | ||
|
|
||
| def test_display_summary(self): | ||
| registry = _make_registry(n_samples=10) | ||
| report = _build_report(registry) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes
test_started_atinresult_summary.json(written byto_json) from0to a rawtime.monotonic_ns()value: nanoseconds since boot, not since the epoch. Only the console "Test started at:" line converts it (monotime_to_datetime). Anyone reading the JSON gets a number that looks like a timestamp but isn't one, and it can't be compared across hosts or reboots.Could we either: