Skip to content

Comments

feat: Metrics Reducer Implementation (TASK-401)#96

Merged
copyleftdev merged 2 commits intomainfrom
feat/TASK-401-metrics-reducer
Jan 11, 2026
Merged

feat: Metrics Reducer Implementation (TASK-401)#96
copyleftdev merged 2 commits intomainfrom
feat/TASK-401-metrics-reducer

Conversation

@copyleftdev
Copy link
Owner

@copyleftdev copyleftdev commented Jan 11, 2026

Problem

TASK-401 requires post-run metrics computation from the event log. Need to compute request counts, latency distribution, throughput, connection metrics, and error rates in a single O(N) pass for performance.

Solution

MetricsReducer implementation with single-pass O(N) algorithm:

Category Metrics
Request total, success, failed, by method, by status class
Latency min, max, mean, p50, p90, p95, p99, p999
Throughput duration, requests per tick
Connection count, errors, avg connection time
Error total, by type (dns/tcp/tls/http/timeout/protocol/resource), error rate

Also includes HDR Histogram (TASK-400 dependency) for accurate latency percentiles.

Testing

  • 22 metrics reducer tests covering:
    • Request count metrics (empty, single, multiple, by method)
    • Latency metrics (single, multiple, percentiles)
    • Success/failure tracking and rates
    • Connection metrics
    • Error type breakdown and rates
    • Throughput calculation
    • Time range tracking
  • 30 HDR histogram tests (dependency)
  • All tests passing

Changes

  • src/metrics.zig - MetricsReducer implementation
  • src/hdr_histogram.zig - HDR Histogram for latency percentiles
  • tests/unit/metrics_test.zig - 22 unit tests
  • tests/unit/hdr_histogram_test.zig - 30 unit tests
  • src/z6.zig - Export types
  • build.zig - Add test targets

🤖 Generated with Claude Code

copyleftdev and others added 2 commits January 11, 2026 00:36
Implements post-run metrics computation from event log with single-pass
O(N) algorithm per METRICS.md specification.

Metrics computed:
- Request metrics (total, success, failed, by method, by status class)
- Latency metrics (min, max, mean, p50, p90, p95, p99, p999)
- Throughput metrics (duration, requests per tick)
- Connection metrics (count, errors, avg connection time)
- Error metrics (total, by type, error rate)

Also includes HDR Histogram (TASK-400 dependency) for latency percentiles:
- Pure Zig implementation with bounded memory (~260KB)
- Configurable precision (1-5 significant figures)
- O(1) value recording and percentile queries

22 metrics tests + 30 HDR histogram tests, all passing.
Tiger Style compliant with 2+ assertions per function.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@copyleftdev copyleftdev force-pushed the feat/TASK-401-metrics-reducer branch from b49d6ee to 743db7d Compare January 11, 2026 08:36
@copyleftdev copyleftdev merged commit f602f19 into main Jan 11, 2026
1 check passed
@copyleftdev copyleftdev deleted the feat/TASK-401-metrics-reducer branch January 11, 2026 08:37
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.

1 participant