feat(DSM): add canister_log_retention_seconds metric#9952
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new scheduler histogram metric (canister_log_retention_seconds) to quantify canister log buffer “retention span” (oldest→newest record timestamp), with support for both the legacy CanisterLog and the new LogMemoryStore implementation.
Changes:
- Introduces
retention()helpers onCanisterLogandLogMemoryStore(including a cachedfirst_timestampfor the latter). - Adds a new
SchedulerMetricshistogram and observes it during scheduler round finalization for canisters that appended logs that round. - Adds unit/integration tests for retention behavior and metric emission.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| rs/types/types/src/canister_log.rs | Adds CanisterLog::retention() and unit tests. |
| rs/replicated_state/src/canister_state/system_state/log_memory_store/ring_buffer.rs | Adds RingBuffer::first_timestamp() helper for retention computation. |
| rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs | Adds cached first_timestamp, plus max_timestamp/first_timestamp/retention APIs and cache lifecycle handling. |
| rs/replicated_state/src/canister_state/system_state/log_memory_store/tests/log_memory_store.rs | Adds lifecycle-focused retention/cache invalidation test. |
| rs/execution_environment/src/scheduler/scheduler_metrics.rs | Registers the new canister_log_retention_seconds histogram. |
| rs/execution_environment/src/scheduler.rs | Observes retention metric at round finalization, activity-gated by delta-log appends. |
| rs/execution_environment/tests/canister_logging.rs | Adds a state-machine test asserting metric sample emission and magnitude. |
| rs/config/src/execution_environment.rs | Flips LOG_MEMORY_STORE_FEATURE_ENABLED to true (currently flagged as “do not submit”). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… into maksym/canister-log-retention
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
canister_log_retention_secondshistogram toSchedulerMetrics— wall-clock span between the oldest and newest records currently in a canister's log buffer.LOG_MEMORY_STORE_FEATURE_ENABLED), giving directly-comparable before/after-flip data on the same histogram. On the new path,first_timestampis cached in a transientOption<u64>onLogMemoryStore, populated eagerly from every mutation site — no header change, no checkpoint migration.decimal_buckets_with_zero(1, 6)→ 19 buckets,[0, 10 s .. ~58 d].Stacked on
Depends on #9948. Base is
maksym/canister-log-metrics; retarget tomasteronce #9948 lands.