feat: Output Formatters for Metrics (TASK-402)#97
Merged
copyleftdev merged 1 commit intomainfrom Jan 11, 2026
Merged
Conversation
Enhance output formatting to support full Metrics structure with multiple output formats per OUTPUT_FORMAT.md specification. New formatters: - formatSummaryText: Human-readable summary with sections for requests, latency, throughput, errors, and connections - formatMetricsJSON: Machine-readable JSON with pretty/compact modes - formatTimeSeriesHeader/Row: CSV time-series for streaming data - formatDiff: Compare two runs with improvement/regression indicators Helper functions: - nsToMs: Convert nanoseconds to milliseconds - formatWithCommas: Number formatting with thousand separators - formatPercent: Percentage formatting with 1 decimal - formatDelta: Delta with direction indicator New types: - OutputConfig: Configuration for output formatting - IntervalMetrics: Data structure for time-series points All 23 tests passing (6 legacy + 17 new). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Problem
The existing output formatters in
src/output.zigonly support a basicTestResultstruct with limited fields. The fullMetricsstructure from TASK-401 contains comprehensive data (requests, latency percentiles, throughput, connections, errors) that needs to be formatted for human-readable summaries, machine-readable JSON, CSV time-series, and comparison diffs.Solution
Enhanced
src/output.zigwith formatters for the fullMetricsstructure:New Formatters:
formatSummaryText()- Human-readable summary with sections for requests, latency (ms), throughput (RPS), errors, and connectionsformatMetricsJSON()- Machine-readable JSON with pretty-print and compact modes, includes by_method and by_status breakdownsformatTimeSeriesHeader()/formatTimeSeriesRow()- CSV time-series format for streaming interval dataformatDiff()- Compare two metric runs with improvement/regression indicatorsHelper Functions:
nsToMs()- Convert nanoseconds to millisecondsformatWithCommas()- Number formatting with thousand separators (e.g., 1,234,567)formatPercent()- Percentage formatting with 1 decimal placeformatDelta()- Delta with direction indicator for comparisonsNew Types:
OutputConfig- Configuration struct for output optionsIntervalMetrics- Data structure for time-series data pointsConvenience Functions:
metricsToJSON()- Allocate JSON string from MetricsmetricsToSummary()- Allocate summary string from MetricsTesting
All 23 tests passing:
TestResulttests (backward compatibility)Metricsformatter tests covering:🤖 Generated with Claude Code