@@ -16,8 +16,7 @@ Each topic has examples to make a custom metric and create [thresholds](/using-k
1616
1717## Create a custom metric
1818
19-
20- <Blockquote mod =" " title =" " >
19+ <Blockquote mod =" note " title =" " >
2120
2221Custom metrics must be created in [ init context] ( /using-k6/test-lifecycle ) .
2322This limits memory and ensures that k6 can validate that all thresholds are evaluating defined metrics.
@@ -43,8 +42,9 @@ The generic procedure to create a custom metric is as follows:
4342
44431 . In the VU iteration code, use the ` add ` method to take a measurement.
4544
46- For example, this VU code makes a request, then adds the timing value of the request to the ` myTrend ` object.
45+ ## Example: create a trend metric for waiting time
4746
47+ This VU code makes a request then adds the timing value of the request to the ` myTrend ` object.
4848
4949<CodeGroup lineNumbers ={[true]} >
5050
@@ -63,9 +63,14 @@ export default function () {
6363
6464</CodeGroup >
6565
66- Custom metrics appear in both the end-of-test summary and in the granular points of the [ Results output] ( /results-output ) .
67- Here's how the output of the preceding script might look.
66+ ## View custom metric results
67+
68+ Custom metrics appear in [ Results output] ( /results-output ) in both the end-of-test summary and in the granular data points.
6869Each metric type has specific aggregation methods.
70+ You can also optionally [ tag] ( /using-k6/tags-and-groups ) any value for a custom metric.
71+ You can use these tags to filter test results.
72+
73+ Here's how the output of the preceding script might look in the end-of-test summary.
6974Since the metric is a trend, k6 calculates various trends based on the number of values and their summation.
7075
7176 <CodeGroup lineNumbers ={[false]} >
@@ -84,9 +89,6 @@ $ k6 run script.js
8489
8590</CodeGroup >
8691
87- You can optionally [ tag] ( /using-k6/tags-and-groups ) any value for a custom metric.
88- You can use these tags to filter test results.
89-
9092<Blockquote mod =" note " title =" " >
9193
9294Custom metrics are collected from VU threads only at the end of a VU iteration.
0 commit comments