feat(metrics): Add histogram metrics support for latency distributions#453
Merged
Conversation
Implement histogram metric class that supports: - Configurable bucket boundaries for value distribution tracking - Thread-safe atomic operations for concurrent recording - Percentile calculations (p50, p95, p99, p999) - Prometheus and JSON format export via snapshot - Linear interpolation for percentile estimation Addresses #409
Implement sliding window histogram that automatically expires old data: - Configurable time window duration and bucket count - Auto-expiring time buckets for recent-only percentile tracking - Aggregated statistics across all active time buckets - Useful for real-time performance monitoring Addresses #409
Add histogram-based metrics methods to metric_reporter: - record_latency/connection_time/request_duration for histogram recording - get_latency_p50/p95/p99 for percentile retrieval - get_all_histograms for bulk snapshot export - reset_histograms for clearing all histogram data New metric names added for histogram tracking: - network.latency.histogram - network.connection_time.histogram - network.request_duration.histogram Addresses #409
Add comprehensive test coverage including: - Histogram basic operations (record, count, sum, min/max) - Percentile calculations (p50, p95, p99) - Custom bucket boundaries - Prometheus and JSON export formats - Thread safety with concurrent reads and writes - Sliding histogram time windowing - metric_reporter histogram integration All 29 tests pass. Addresses #409
Add documentation for histogram metrics implementation (#409): - histogram and sliding_histogram classes - metric_reporter integration - Prometheus and JSON export formats - Comprehensive test coverage Updated both English and Korean CHANGELOGs.
Contributor
Performance ComparisonBase Branch ResultsNo base results PR Branch ResultsNo PR results |
kcenon
added a commit
that referenced
this pull request
Apr 13, 2026
#453) * feat(metrics): add histogram class for latency distributions Implement histogram metric class that supports: - Configurable bucket boundaries for value distribution tracking - Thread-safe atomic operations for concurrent recording - Percentile calculations (p50, p95, p99, p999) - Prometheus and JSON format export via snapshot - Linear interpolation for percentile estimation Addresses #409 * feat(metrics): add sliding_histogram for time-windowed tracking Implement sliding window histogram that automatically expires old data: - Configurable time window duration and bucket count - Auto-expiring time buckets for recent-only percentile tracking - Aggregated statistics across all active time buckets - Useful for real-time performance monitoring Addresses #409 * feat(metrics): integrate histogram metrics with metric_reporter Add histogram-based metrics methods to metric_reporter: - record_latency/connection_time/request_duration for histogram recording - get_latency_p50/p95/p99 for percentile retrieval - get_all_histograms for bulk snapshot export - reset_histograms for clearing all histogram data New metric names added for histogram tracking: - network.latency.histogram - network.connection_time.histogram - network.request_duration.histogram Addresses #409 * test(metrics): add unit tests for histogram and sliding_histogram Add comprehensive test coverage including: - Histogram basic operations (record, count, sum, min/max) - Percentile calculations (p50, p95, p99) - Custom bucket boundaries - Prometheus and JSON export formats - Thread safety with concurrent reads and writes - Sliding histogram time windowing - metric_reporter histogram integration All 29 tests pass. Addresses #409 * docs: update CHANGELOG with histogram metrics feature Add documentation for histogram metrics implementation (#409): - histogram and sliding_histogram classes - metric_reporter integration - Prometheus and JSON export formats - Comprehensive test coverage Updated both English and Korean CHANGELOGs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
histogramclass for capturing value distributions with configurable bucket boundariessliding_histogramclass for time-windowed percentile tracking (auto-expiring old data)metric_reporterfor seamless usageChanges
New Files
include/kcenon/network/metrics/histogram.h- Histogram class with percentile calculationsinclude/kcenon/network/metrics/sliding_histogram.h- Time-windowed histogramsrc/metrics/histogram.cpp- Histogram implementationsrc/metrics/sliding_histogram.cpp- Sliding histogram implementationtests/unit/test_histogram.cpp- Comprehensive unit tests (29 tests)Modified Files
include/kcenon/network/metrics/network_metrics.h- Added histogram methods to metric_reportersrc/metrics/network_metrics.cpp- Implemented histogram integrationCMakeLists.txt- Added new source filestests/CMakeLists.txt- Added histogram test targetdocs/CHANGELOG.md- Documented new featuredocs/CHANGELOG_KO.md- Korean changelog updateFeatures
histogram class
sliding_histogram class
metric_reporter integration
record_latency(),record_connection_time(),record_request_duration()get_latency_p50(),get_latency_p95(),get_latency_p99()get_all_histograms()for bulk exportreset_histograms()for clearing dataTest plan
Closes #409