feat(#608): human-readable formatting for stats numbers - #824
Open
tkhhhh wants to merge 13 commits into
Open
Conversation
…human-readable-metric
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
Enhancement for #608. The stats tab currently shows raw numeric metrics — nanosecond CPU counters and byte counts — that are hard to read at a glance (e.g.
system_cpu_usage: 93579438000000,memory_stats.limit: 2052030464). This PR formats those values into human-readable units before rendering the YAML.µs,ms,s,m,h(base 1000)KB,MB,GB,TB(base 1024)Before / After
Changes
pkg/utils/utils.gopkg/gui/presentation/container_stats.gousage_in_usermode, percpu_usage, system_cpu_usage) and memory_stats (limit, stats.hierarchical_memory_limit, stats.hierarchical_memsw_limit).
Tests
pkg/utils/utils_test.go— table tests for FormatBigMetric (unit thresholds, sub-unit values, unknown unit) and SetObjectFieldByPath (nested writes, invalid path).pkg/gui/presentation/container_stats_test.go— table tests covering scalar byte/nanosecond conversion, the percpu_usage array path, deeply nested hierarchical_*_limit fields, both cpu_stats and precpu_stats branches, preservation of non-whitelisted fields, and a realistic full-payload snapshot.Test Result