Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Jakub Kicinski
Fri, 16 Oct 2026 16:52
Re: [RFC net-next v2 1/5] selftests: net: py: add timestamped metric output
Author: Jakub Kicinski
Date: Fri, 16 Oct 2026 16:52
Date: Fri, 16 Oct 2026 16:52
42 lines
7046 bytes
7046 bytes
On Mon, 5 Oct 2026 13:11:10 -0700 Stanislav Fomichev wrote:
> +ksft_metric()
> +~~~~~~~~~~~~~
> +
> +Use ``ksft_metric()`` to report a numeric measurement for the current test
> +case. The helper records the time relative to the start of the case and emits
> +each observation immediately before the test result as compact JSON. For
> +example::
> +
> + ksft_metric("throughput", 100.5, kind="scalar")
> +
> +emits output similar to::
> +
> + # ktap-metric-json: {"name":"throughput","time":1.234,"type":"scalar","value":100.5}
Should time be optional? In case some test wants to report single metric
not value over time? Maybe just mention that it's an option if someone
needs it in the future?
> +When ``run_kselftest.sh`` nests the test output, its diagnostic prefix makes
> +this ``# # ktap-metric-json: <json>``.
This sentence needs to go, it's out of place and obvious to anyone who
worked with ksft.
> A background sampler can call
> +``ksft_metric()`` repeatedly. Pass ``kind`` explicitly; it is emitted as the
> +``type`` field. Supported kinds are ``scalar`` for one numeric value and
> +``per-cpu`` for an array indexed by CPU number, with ``None`` for a missing or
> +offline CPU::
> +
> + ksft_metric("cpu.utilization", [75.0, 22.0, None, 100.0],
> + kind="per-cpu", host="local")
Should we say something about what the values for "kind" are?
Or should this be internal - IOW create ksft_metric_X for supported
types, like ksft_metric_scalar, which would be more self-documenting?
> +The helper does not infer the kind from the Python value, since an array may
> +represent something other than per-CPU data. Metrics are measurements only and
> +do not affect the pass or fail result.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads