Skip to content

[REFACTOR] Consolidate load_average_history with time_series_buffer #311

Description

@kcenon

Summary

Consolidate load_average_history class with time_series_buffer<T> template to eliminate code duplication.

Parent Issue

Part of #309 (Consolidate buffering layer - C++20 Module preparation)

Current State

  • time_series_buffer.h contains two nearly identical implementations:
    • time_series_buffer<T>: Generic time-series buffer for arithmetic types
    • load_average_history: Specialized buffer for load average (3 double values)

Problem

  • Both classes share ~90% identical code structure (ring buffer logic, statistics calculation)
  • Violates Kent Beck's "No Duplication" principle
  • Makes maintenance harder - bug fixes must be applied twice

Proposed Solution

  1. Create multi_value_time_series_buffer<T, N> template or similar for multi-field samples
  2. Refactor load_average_history to use the new template or a specialized time_series_buffer
  3. Mark old API as deprecated (if breaking changes not allowed)

Acceptance Criteria

  • Single ring buffer implementation for time-series data
  • load_average_history functionality preserved
  • system_resource_collector continues to work
  • Tests pass
  • No breaking changes to public API (use deprecation if needed)

Files Affected

  • include/kcenon/monitoring/utils/time_series_buffer.h
  • include/kcenon/monitoring/collectors/system_resource_collector.h
  • tests/test_time_series_buffer.cpp

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions