Skip to content

feat(DSM): add canister_log_retention_seconds metric#9952

Merged
maksymar merged 19 commits intomasterfrom
maksym/canister-log-retention
Apr 21, 2026
Merged

feat(DSM): add canister_log_retention_seconds metric#9952
maksymar merged 19 commits intomasterfrom
maksym/canister-log-retention

Conversation

@maksymar
Copy link
Copy Markdown
Contributor

@maksymar maksymar commented Apr 20, 2026

Summary

  • Add canister_log_retention_seconds histogram to SchedulerMetrics — wall-clock span between the oldest and newest records currently in a canister's log buffer.
  • Activity-gated observation at round finalization; cost scales with activity, not canister count.
  • Works on both log stores (branched on LOG_MEMORY_STORE_FEATURE_ENABLED), giving directly-comparable before/after-flip data on the same histogram. On the new path, first_timestamp is cached in a transient Option<u64> on LogMemoryStore, populated eagerly from every mutation site — no header change, no checkpoint migration.
  • Buckets: 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 to master once #9948 lands.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 on CanisterLog and LogMemoryStore (including a cached first_timestamp for the latter).
  • Adds a new SchedulerMetrics histogram 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.

Comment thread rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs Outdated
Comment thread rs/execution_environment/tests/canister_logging.rs Outdated
Comment thread rs/config/src/execution_environment.rs Outdated

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@maksymar maksymar marked this pull request as ready for review April 21, 2026 05:27
@maksymar maksymar requested review from a team as code owners April 21, 2026 05:27
Comment thread rs/config/src/execution_environment.rs Outdated
Comment thread rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs Outdated
Comment thread rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Base automatically changed from maksym/canister-log-metrics to master April 21, 2026 09:06
Comment thread rs/replicated_state/src/canister_state/system_state/log_memory_store/mod.rs Outdated
Comment thread rs/execution_environment/src/scheduler.rs
@maksymar maksymar enabled auto-merge April 21, 2026 12:27
@maksymar maksymar added this pull request to the merge queue Apr 21, 2026
Merged via the queue into master with commit 09a5f7d Apr 21, 2026
37 checks passed
@maksymar maksymar deleted the maksym/canister-log-retention branch April 21, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants