Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request failed metric #881

Merged
merged 3 commits into from
May 25, 2023
Merged

Add request failed metric #881

merged 3 commits into from
May 25, 2023

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented May 12, 2023

Description of changes

When a request completes we want to measure how many of these failed. This is based on the status code of the response. If the code is outside of the 200-399 range, it is deemed to have failed. The default status code range was taken from k6.

The opposite is also possible to determine, we can work out which requests succeeded since the value of the metric will be 0.

We're using a custom metric named browser_http_req_failed, instead of the builtin k6 http_req_failed. There was a concern that if the browser module worked with the builtin k6 metric, then the results would be skewed for both modules and therefore meaningless. This is due to the fact that the implementation of http could differ. Users are also likely to want to understand their API http failures differently to their browser level http failures.

The shape of the data is free to be moulded the best way that works for the browser module use case. I tested to see whether the cache values varied, which they did, so I've left them in. We can adjust the metrics and labels as we see fit once we have a better idea of what users require.

Testing

To test this change, influxdb will need to installed or another suitable backend time series database. Once installed, run a test that you know will navigate to a website which has failing dependencies (e.g. an image that doesn't load). You should see something like this in the http_req_failed table:

Screenshot 2023-05-12 at 14 11 27

You should also see metric in the end summary:

browser_http_req_failed............: 0.00%  ✓ 0         ✗ 218

@ankur22 ankur22 marked this pull request as draft May 12, 2023 13:34
@ankur22 ankur22 force-pushed the fix/1261-failed-request-metric branch 2 times, most recently from 94d450c to e124756 Compare May 23, 2023 16:13
@ankur22 ankur22 changed the base branch from main to rename/883-browser-prefix-metrics May 23, 2023 16:13
@ankur22 ankur22 force-pushed the fix/1261-failed-request-metric branch from 01d0210 to 015ee2e Compare May 23, 2023 16:24
@ankur22 ankur22 requested review from inancgumus and ka3de May 24, 2023 13:56
@ankur22 ankur22 marked this pull request as ready for review May 24, 2023 13:58
@ankur22 ankur22 requested a review from dgzlopes May 24, 2023 14:52
Base automatically changed from rename/883-browser-prefix-metrics to main May 24, 2023 14:54
Copy link
Collaborator

@ka3de ka3de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment. Also there is a conflict in k6ext/metrics.go, but the rest, as for 10c9708 and 015ee2e LGTM.

common/network_manager.go Outdated Show resolved Hide resolved
ankur22 and others added 3 commits May 25, 2023 09:14
This metric is predefined in k6. When a request completes we want to
measure how many of these failed. This is based on the status code of
the response. If the code is outside of the 200-399 range, it is deemed
to have failed. The default status code range was taken from k6.

The opposite is also possible to determine, we can work out which
requests succeeded since the value of the metric will be 0.
This commit helps us move away from the k6 http_req_failed metric to
a browser prefixed one. It is custom to the browser module allowing the
user to measure k6 vs browser http_req_failed metrics separately.
Co-authored-by: ka3de <daniel.jimenez@grafana.com>
@ankur22 ankur22 force-pushed the fix/1261-failed-request-metric branch from 6221bb9 to ae0319a Compare May 25, 2023 08:14
Copy link
Collaborator

@ka3de ka3de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ankur22 ankur22 merged commit 78d5fa4 into main May 25, 2023
@ankur22 ankur22 deleted the fix/1261-failed-request-metric branch May 25, 2023 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants