Skip to content

feat(interfaces): add unified metric collection interface (IMetricCollector)#236

Merged
kcenon merged 3 commits into
mainfrom
feature/issue-234-metric-collector-interface
Dec 26, 2025
Merged

feat(interfaces): add unified metric collection interface (IMetricCollector)#236
kcenon merged 3 commits into
mainfrom
feature/issue-234-metric-collector-interface

Conversation

@kcenon

@kcenon kcenon commented Dec 26, 2025

Copy link
Copy Markdown
Owner

Summary

  • Add IMetricCollector interface for cross-module metric reporting without direct monitoring_system dependencies
  • Implement scoped_timer RAII helper for automatic timing measurements
  • Implement null_metric_collector for disabled metrics scenarios
  • Add IMetricCollectorProvider for dependency injection support
  • Add monitoring.h umbrella header and comprehensive unit tests (31 tests)

Changes

File Description
include/.../monitoring/metric_collector_interface.h Core interface implementation
include/.../monitoring.h Umbrella header
tests/metric_collector_interface_test.cpp Comprehensive unit tests
tests/CMakeLists.txt Test configuration
docs/CHANGELOG.md English documentation
docs/CHANGELOG_KO.md Korean documentation

Interface Design

// Counter - monotonically increasing value
collector->increment("http_requests_total", 1.0, {{"method", "GET"}});

// Gauge - value that can go up or down
collector->gauge("active_connections", 42.0);

// Histogram - distribution of values
collector->histogram("request_size_bytes", 1024.0);

// Timing - duration measurement
collector->timing("request_duration", std::chrono::milliseconds{150});

// RAII timer for automatic timing
{
    scoped_timer timer(*collector, "operation_time");
    // ... do work ...
} // Timer automatically reports on scope exit

Relationship with Existing IMonitor

  • IMonitor: Pull-based (read status, get snapshots)
  • IMetricCollector: Push-based (emit metrics in real-time)

Both interfaces complement each other in the monitoring ecosystem.

Test Plan

  • All 31 unit tests passing
  • Counter, gauge, histogram, timing metrics tested
  • scoped_timer RAII behavior verified
  • null_metric_collector no-op implementation tested
  • Polymorphism and interface contracts verified

Downstream Impact

Repository Change Required
monitoring_system Implement IMetricCollector adapter
network_system Use IMetricCollector instead of direct monitoring_system
thread_system Migrate to IMetricCollector from local monitoring_interface
database_system Use IMetricCollector for query metrics

Resolves #234

Part of Epic #232 (Cross-Module Circular Dependency Resolution)

…ollection

Add IMetricCollector interface to enable cross-module metric reporting
without requiring direct monitoring_system dependencies.

- Add IMetricCollector interface with counter/gauge/histogram/timing methods
- Add scoped_timer RAII helper for automatic timing measurements
- Add null_metric_collector for disabled metrics scenarios
- Add IMetricCollectorProvider for dependency injection support
- Add monitoring.h umbrella header

This complements the existing IMonitor interface:
- IMonitor: Pull-based (read status, get snapshots)
- IMetricCollector: Push-based (emit metrics in real-time)

Resolves #234
Add comprehensive test coverage for the new metric collector interface:
- MockMetricCollector for testing metric emissions
- Tests for counter, gauge, histogram, and timing metrics
- Tests for metric labels functionality
- Tests for scoped_timer RAII behavior
- Tests for null_metric_collector no-op implementation
- Polymorphism tests for interface contracts

All 31 tests passing.

Related to #234
Add documentation for the unified metric collection interface
in both English and Korean CHANGELOG files.
@kcenon kcenon merged commit f7db7bf into main Dec 26, 2025
19 checks passed
@kcenon kcenon deleted the feature/issue-234-metric-collector-interface branch December 26, 2025 01:57
kcenon added a commit that referenced this pull request Apr 13, 2026
…lector) (#236)

* feat(interfaces): add IMetricCollector interface for unified metric collection

Add IMetricCollector interface to enable cross-module metric reporting
without requiring direct monitoring_system dependencies.

- Add IMetricCollector interface with counter/gauge/histogram/timing methods
- Add scoped_timer RAII helper for automatic timing measurements
- Add null_metric_collector for disabled metrics scenarios
- Add IMetricCollectorProvider for dependency injection support
- Add monitoring.h umbrella header

This complements the existing IMonitor interface:
- IMonitor: Pull-based (read status, get snapshots)
- IMetricCollector: Push-based (emit metrics in real-time)

Resolves #234

* test(interfaces): add unit tests for IMetricCollector interface

Add comprehensive test coverage for the new metric collector interface:
- MockMetricCollector for testing metric emissions
- Tests for counter, gauge, histogram, and timing metrics
- Tests for metric labels functionality
- Tests for scoped_timer RAII behavior
- Tests for null_metric_collector no-op implementation
- Polymorphism tests for interface contracts

All 31 tests passing.

Related to #234

* docs: update CHANGELOG for IMetricCollector interface

Add documentation for the unified metric collection interface
in both English and Korean CHANGELOG files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deps: Add unified metric collection interface (IMetricCollector)

1 participant