You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/data/markdown/translated-guides/en/03 Using k6 browser/03 Metrics.md
+101-8Lines changed: 101 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,16 +5,45 @@ excerpt: 'An overview of the different browser performance metrics that the brow
5
5
6
6
Follow along to learn about:
7
7
8
-
1. The existing browser metrics that k6 browser tracks
9
-
2. The Web Vitals and why they are important
10
-
3. How to set thresholds for your browser metrics
11
-
4. How to separate the browser metrics for different pages
8
+
1. Google's Core Web Vitals and why they are important
9
+
2. The existing browser metrics that k6 browser tracks
10
+
3. How to analyze the browser metrics output
11
+
4. How to set thresholds for your browser metrics
12
+
## Google's Core Web Vitals
12
13
14
+
In order to provide users with the best user experience, Google introduced [Core Web Vitals](https://web.dev/vitals/#core-web-vitals) which consists of three important metrics to help you measure your user's experience when using your web application. In a nutshell, it gives you an indication of your page's:
15
+
16
+
1. loading performance,
17
+
2. interactivity,
18
+
3. and visual stability.
19
+
20
+
These core metrics will evolve over time when technology changes, but for now, k6 tracks the following core web vitals:
| webvital_largest_content_paint | Measures a page's loading performance. Please refer to [Largest Contentful Paint](https://web.dev/lcp/) for more information. |
25
+
| webvital_first_input_delay | Measures a page's interactivity. Please refer to [First Input Delay](https://web.dev/fid/) for more information. |
26
+
| webvital_cumulative_layout_shift | Measures a page's visual stabilty. Please refer to [Cumulative Layout Shift](https://web.dev/cls/) for more information. |
27
+
### Other Web Vitals
28
+
29
+
Apart from the Core Web Vitals, the browser module also reports [Other Web Vitals](https://web.dev/vitals/#other-web-vitals).
| webvital_time_to_first_byte | Measures the time it takes between the browser request and the start of the response from a server. Please refer to [Time to First Byte](https://web.dev/ttfb/) for more information.|
35
+
| webvital_first_contentful_paint | Measures the time it takes for the browser to render the first DOM element on the page, whether that's a text, image or header. Please refer to [First Contentful Paint](https://web.dev/fcp/) for more information. |
36
+
| webvital_interaction_to_next_paint | An experimental metric that measures a page's responsiveness. Please refer to [Interaction to Next Paint](https://web.dev/inp/) for more information. |
37
+
### Why are they important?
38
+
39
+
The Core Web Vitals comprise one of [Google's Page Experience Signals](https://developers.google.com/search/docs/appearance/page-experience). A positive page experience naturally leads to better quality and better search engine rankings. These golden metrics help you understand which areas of your frontend application need optimization so your pages can rank higher than similar content.
40
+
41
+
Existing browser measures such as the `Load` and `DOMContentLoaded` time do not accurately reflect the user's experience very well as they used to. Relying on these load events does not give the correct metric to analyze critical performance bottlenecks that your page might have. Google's Web Vitals is a better measure of your page's performance as well as your page's user experience.
13
42
## Existing browser metrics
14
43
15
44
<Blockquotemod="note"title="">
16
45
17
-
As of k6 version 0.44.0, k6 browser now natively supports [Web Vitals](https://web.dev/vitals/). In future releases, we will remove the following browser metrics to focus on the standard web vital metrics.
46
+
As of k6 version 0.44.0, k6 now natively supports [Google's Core Web Vitals](https://web.dev/vitals/#core-web-vitals). In future releases, to align with recommended practices, we will remove the following browser metrics to focus on the web vital metrics. Please refer to [#831](https://github.com/grafana/xk6-browser/issues/831) for more information.
18
47
19
48
</Blockquote>
20
49
@@ -27,10 +56,74 @@ Apart from the usual HTTP specific metrics that k6 already tracks, the browser m
27
56
| browser_first_contentful_paint | Emitted when the browser renders the first DOM element on the page, whether that's a text, image or header. |
28
57
| browser_loaded | Emitted when the page is fully loaded. |
29
58
30
-
## Web vitals
59
+
## Understanding the browser metrics output
31
60
32
-
### Why are they important?
61
+
When a browser test is finished, k6 reports a top-level overview of the aggregated browser metrics output. A sample of which you can see below.
62
+
63
+
<Blockquotemod="note"title="">
64
+
65
+
As mentioned previously, in future releases, the `browser_*` metrics will be removed in favour of the web vitals. As Google also recommends measuring the 75th percentile for each web vital metric, there will still be future tweaks to improve the summary output.
After each web vital metric, an additional row with the same metric name is also printed with its rating. The rating can be `good`, `needs_improvement,` or `poor`. When the browser module receives the metric from the [Google's Web Vital Library](https://github.com/GoogleChrome/web-vitals), it counts how many times it sees that metric.
88
+
89
+
For example, `webvital_first_contentful_paint_good` was reported twice, indicating that this metric was seen on two pages and has a rating of good. In future releases of k6, we aim to improve how to display the rating for a better developer experience.
90
+
91
+
You can also visualize these results in different ways depending on your team's needs. For more information, check out our blog post on [visualizing k6 results](https://k6.io/blog/ways-to-visualize-k6-results/).
34
92
## Set thresholds for your browser metrics
35
93
36
-
## Separate browser metrics for different pages
94
+
The great thing about the browser module is it can easily use all of k6's key functionalities, such as [Thresholds](https://k6.io/docs/using-k6/thresholds/).
95
+
96
+
To set thresholds for your browser metrics, add the metric you want to check and specify its threshold value. As seen in the example below, you can also pass in different URLs if you're going to set a threshold for other pages, especially when your script contains page navigations.
97
+
98
+
<Blockquotemod="attention">
99
+
100
+
Currently, you can only use URLs to specify thresholds for different pages. If you use [Groups](https://k6.io/docs/using-k6/tags-and-groups/#groups), the metrics are not correctly grouped as described in [#721](https://github.com/grafana/xk6-browser/issues/721).
0 commit comments