Skip to content

Add ContractMonitor MTTR and MTBF derived metrics with rolling windows #667

Description

@greatest0fallt1me

Description

monitoring.rs records incidents but exposes only counts. Compute and surface rolling Mean Time To Recovery and Mean Time Between Failures over a configurable window so operators can spot deteriorating reliability before it triggers the circuit breaker.

Requirements and Context

  • Add RollingWindow { capacity: u32 } ring buffer
  • Compute MTTR/MTBF in seconds as i128
  • Window writes are bounded and replace oldest entries
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b feature/monitoring-mttr-mtbf
  2. Implement changes
    • contracts/predictify-hybrid/src/monitoring.rs
    • contracts/predictify-hybrid/src/tests/monitoring_mttr_tests.rs
  3. Test and commit
    • cargo test -p predictify-hybrid mttr_mtbf
    • Cover edge cases
    • Include test output and notes in the PR

Example commit message

feat: expose rolling MTTR and MTBF metrics from ContractMonitor

Acceptance Criteria

  • MTTR/MTBF queryable through view functions
  • Window capacity is admin-configurable within sane bounds
  • Property test: averages match brute-force on small windows

Guidelines

  • No unwrap() in production paths
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GRANTFOX OSSGrantFox open-source campaign taskOFFICIAL CAMPAIGNOfficial GrantFox campaign issueStellar WaveIssues in the Stellar wave programenhancementNew feature or improvementrustRust implementationsmart-contractSoroban smart-contract worksorobanSoroban SDK / Stellar

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions