Skip to content

feat(report): support multiple presave intervals in flight - #23

Merged
onkwon merged 1 commit into
mainfrom
feature/multiple-presave
May 8, 2026
Merged

feat(report): support multiple presave intervals in flight#23
onkwon merged 1 commit into
mainfrom
feature/multiple-presave

Conversation

@onkwon

@onkwon onkwon commented May 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@onkwon
onkwon requested a review from Copilot May 8, 2026 12:29
@onkwon onkwon self-assigned this May 8, 2026
@onkwon onkwon added the enhancement New feature or request label May 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Pulse’s async reporting flow so that, while a report is “in flight” (-EINPROGRESS), the SDK can periodically presave multiple elapsed live-metrics intervals to the backlog (metricfs) without altering the original in-flight payload.

Changes:

  • Update in-flight presave interval logic to anchor against the max of last_report_time and the in-flight report’s window_end, enabling multiple presaves during one in-flight session.
  • Add a dedicated live-payload-to-buffer collection path used for in-flight presaves, then reset metrics and advance last_report_time per presaved window.
  • Extend metricfs test stubs to expose stored entries by index, and add tests covering multiple presaves during a single in-flight report.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pulse.c Implements multi-interval in-flight presave logic, new window bound computation, and presave write path.
include/pulse/pulse_internal.h Renames the in-flight presave tracking flag in the internal report context.
tests/src/pulse_report_test.cpp Adds a test validating multiple presaves while a report remains in progress; minor assertion refactor.
tests/stubs/metricfs_stub.h Adds APIs to read stubbed backlog entries by index for tests.
tests/stubs/metricfs_stub.c Implements indexed accessors for stored backlog entries in the metricfs stub.
Comments suppressed due to low confidence (1)

src/pulse.c:426

  • When an in-flight LIVE report has already been presaved to backlog, abort_flight() saves the original in-flight payload via metricfs_write(), which appends it after the newer presaved entries. This produces backlog entries out of chronological order (older window written after newer windows), which can violate the documented “oldest-first” replay expectation. Consider preserving the original in-flight payload separately and ensuring it is enqueued ahead of newer presaves (or otherwise maintaining chronological ordering) when an abort occurs.
	if (m.live_presave_during_flight) {
		/* Preserve the original in-flight payload as-is. This keeps
		 * its LIVE reason and may append it after newer backlog data.
		 * A fuller fix should store the original payload separately
		 * from the mutable flight buffer, then rebuild or annotate that
		 * payload with BACKLOG_FAILURE/BACKLOG_CANCEL before enqueueing
		 * it in chronological order, without re-collecting from the
		 * already-reset metrics store. */
		*saved = save_current_flight_to_backlog();
		return PULSE_STATUS_OK;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/pulse.c
Comment on lines +591 to 601
const size_t payload_len = metrics_collect(NULL, 0u, NULL);
size_t payload_bufsize = 0u;
size_t encoded_len = 0u;
uint64_t presave_window_end = 0u;
const bool should_presave = is_live_presave_interval_reached(
metrics_get_unix_timestamp());

if (!should_presave) {
return PULSE_STATUS_OK;
}

Comment thread src/pulse.c
Comment on lines +621 to +623
if (status == PULSE_STATUS_EMPTY) {
status = PULSE_STATUS_OK;
}
@onkwon
onkwon force-pushed the feature/multiple-presave branch from 96a0091 to 1b66d17 Compare May 8, 2026 12:42
@onkwon
onkwon merged commit 032e690 into main May 8, 2026
0 of 9 checks passed
@onkwon
onkwon deleted the feature/multiple-presave branch May 8, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants