Summary
Create a comprehensive guide for developing custom collectors, covering the CRTP base class pattern, platform-specific implementations, thread safety, and testing strategies.
Parent Issue
Part of: [EPIC] docs: Address documentation gaps across all ecosystem systems (kcenon/common_system#325)
Background (Why)
monitoring_system has 18 built-in collectors across 4 categories (core, utility, hardware, container). The system is designed for extensibility via collector_base.h (CRTP pattern) and the plugin system. However, there is no dedicated guide for creating custom collectors. The plugin_development_guide.md covers plugin-level integration but not the collector implementation details.
Source files:
include/kcenon/monitoring/collectors/collector_base.h — CRTP base class
include/kcenon/monitoring/interfaces/metric_collector_interface.h — Collector interface
include/kcenon/monitoring/factory/collector_adapters.h — Factory registration
include/kcenon/monitoring/factory/metric_factory.h — Collector creation
Scope (What)
Create docs/guides/COLLECTOR_DEVELOPMENT.md covering:
1. Collector Architecture
collector_base<Derived> CRTP pattern explanation
metric_collector_interface contract
- Collection lifecycle: initialize → collect → report → cleanup
- Registration via
metric_factory
2. Implementing a Custom Collector
class my_collector : public collector_base<my_collector> {
// Step-by-step implementation guide
};
3. Platform-Specific Collectors
- How existing collectors handle Linux/macOS/Windows
platform/metrics_provider.h platform abstraction
- Conditional compilation patterns
- Stub behavior on unsupported platforms
4. Thread Safety Requirements
- What thread safety guarantees collectors must provide
- Thread-local buffer integration
- Atomic operations for metric updates
- Safe shutdown procedures
5. Factory Registration
- How to register via
metric_factory
- Dynamic loading via plugin system
- Configuration-driven collector selection
6. Testing Custom Collectors
- Unit testing patterns
- Mock metric reporting
- Performance benchmarking
- Platform-specific testing strategies
7. Reference: Built-in Collector Catalog
| Category |
Collector |
Metrics |
Platform |
| Core |
system_resource_collector |
CPU, memory, disk |
All |
| Core |
network_metrics_collector |
Socket, TCP states |
Linux/macOS |
| Core |
process_metrics_collector |
FD, inodes, ctx switches |
Linux |
| Core |
platform_metrics_collector |
Platform-specific |
All |
| Core |
thread_system_collector |
Thread pool stats |
All |
| Core |
logger_system_collector |
Logger stats |
All |
| Utility |
uptime_collector |
System uptime |
All |
| Utility |
vm_collector |
Virtual memory stats |
Linux |
| Utility |
interrupt_collector |
Hardware interrupts |
Linux |
| Utility |
security_collector |
Security events |
All |
| Utility |
smart_collector |
Disk SMART health |
Linux |
| Hardware |
battery_collector |
Battery status |
Linux/macOS |
| Hardware |
power_collector |
Power consumption |
Linux |
| Hardware |
temperature_collector |
Thermal sensors |
Linux |
| Hardware |
gpu_collector |
GPU metrics |
Linux (NVIDIA) |
| Container |
container_collector |
Docker/K8s metrics |
Linux |
Acceptance Criteria
Summary
Create a comprehensive guide for developing custom collectors, covering the CRTP base class pattern, platform-specific implementations, thread safety, and testing strategies.
Parent Issue
Part of: [EPIC] docs: Address documentation gaps across all ecosystem systems (kcenon/common_system#325)
Background (Why)
monitoring_system has 18 built-in collectors across 4 categories (core, utility, hardware, container). The system is designed for extensibility via
collector_base.h(CRTP pattern) and the plugin system. However, there is no dedicated guide for creating custom collectors. Theplugin_development_guide.mdcovers plugin-level integration but not the collector implementation details.Source files:
include/kcenon/monitoring/collectors/collector_base.h— CRTP base classinclude/kcenon/monitoring/interfaces/metric_collector_interface.h— Collector interfaceinclude/kcenon/monitoring/factory/collector_adapters.h— Factory registrationinclude/kcenon/monitoring/factory/metric_factory.h— Collector creationScope (What)
Create
docs/guides/COLLECTOR_DEVELOPMENT.mdcovering:1. Collector Architecture
collector_base<Derived>CRTP pattern explanationmetric_collector_interfacecontractmetric_factory2. Implementing a Custom Collector
3. Platform-Specific Collectors
platform/metrics_provider.hplatform abstraction4. Thread Safety Requirements
5. Factory Registration
metric_factory6. Testing Custom Collectors
7. Reference: Built-in Collector Catalog
Acceptance Criteria