feat(report): support multiple presave intervals in flight - #23
Merged
Conversation
There was a problem hiding this comment.
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_timeand the in-flight report’swindow_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_timeper 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 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 on lines
+621
to
+623
| if (status == PULSE_STATUS_EMPTY) { | ||
| status = PULSE_STATUS_OK; | ||
| } |
onkwon
force-pushed
the
feature/multiple-presave
branch
from
May 8, 2026 12:42
96a0091 to
1b66d17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.