@@ -9,20 +9,20 @@ Defining Metrics
99------------------
1010
1111buildtest provides a method to define test metrics in the buildspecs which can be used to
12- store arbitrary content from the output/error file into named metric. A metric is
13- defined using the ``metrics `` property where each element under the ** metrics ** property
14- is the name of the metric which must be a unique name. A metric can apply regular expression
15- on stdout, stderr like in this example below. The metrics are captured in the test report which can
16- be queried via `` buildtest report `` or ``buildtest inspect ``. Shown below is an example
17- where we define two metrics named `` hpcg_rating `` and `` hpcg_state `` .
12+ store arbitrary content from the output/error file or an arbitrary file into named metric. The
13+ ``metrics `` property is used to define a list of metric names using regular expression to assign a value
14+ to the metric. In this example, we have two tests that define metrics `` hpcg_rate_stream ``, `` hpcg_state_stream ``
15+ in the first test and `` hpcg_rate_file ``, `` hpcg_state_file `` in the second test. The `` stream `` property is used
16+ to read from stdout/stderr and apply the regular expression defined by `` exp ``, whereas ``file `` will read
17+ from an arbitrary file name of your choice .
1818
1919.. literalinclude :: ../tutorials/metrics_regex.yml
2020 :language: yaml
21- :emphasize-lines: 8-19
21+ :emphasize-lines: 8-19,27-37
2222
23- The metrics will not impact behavior of test, it will only impact the test report. By default
24- a metric will be an empty dictionary if there is no ``metrics `` property. If we fail to match
25- a regular expression, the metric will be defined as an empty string.
23+ The metrics can be used with :ref: ` comparison_operators ` for performing more sophisticated status checks.
24+ By default, a metric will be an empty dictionary if there is no ``metrics `` property. If we fail to match
25+ a regular expression, the metric will be defined as an empty string (`` '' ``) .
2626
2727.. Note ::
2828 If your regular expression contains an escape character ``\ `` you must surround your
@@ -34,7 +34,15 @@ Let's build this test.
3434
3535 .. command-output :: buildtest build -b tutorials/metrics_regex.yml
3636
37- We can query the metrics via ``buildtest report `` which will display all metrics as a comma separted
37+ The metrics are captured in the test report which can
38+ be queried via ``buildtest report `` or ``buildtest inspect query ``. Metrics can be seen in the test metadata,
39+ for instance you can run ``buildtest inspect query `` and you will see metrics shown in table output.
40+
41+ .. dropdown :: ``buildtest inspect query metric_regex_example metric_file_regex
42+
43+ .. command-output :: buildtest inspect query metric_regex_example metric_file_regex
44+
45+ We can query the metrics via ``buildtest report `` which will display all metrics as a comma seperated
3846**Key/Value ** pair. We can use ``buildtest report --format metrics `` to extract all metrics for a test.
3947Internally, we store the metrics as a dictionary but when we print them out via ``buildtest report `` we
4048join them together into a single string. Shown below is the metrics for the previous build.
@@ -43,12 +51,7 @@ join them together into a single string. Shown below is the metrics for the prev
4351
4452 .. command-output :: buildtest report --filter buildspec=tutorials/metrics_regex.yml --format name,metrics
4553
46- You can define a metric based on :ref: `variables <variables >` or :ref: `environment variables <environment_variables >`
47- which requires you have set ``vars `` or ``env `` property in the buildspec. The ``vars `` and
48- ``env `` is a property under the metric name that can be used to reference name
49- of variable or environment variable. If you reference an invalid name, buildtest will assign the metric an empty string.
50- In this next example, we define two metrics ``gflop `` and ``foo `` that are assigned to variable ``GFLOPS `` and
51- environment variable ``FOO ``.
54+ .. _comparison_operators :
5255
5356Comparison Operators
5457----------------------
0 commit comments