grafana / synthetic-monitoring-agent

Synthetic Monitoring Agent
https://grafana.com/docs/grafana-cloud/how-do-i/synthetic-monitoring/
Apache License 2.0
157 stars 20 forks source link

k6runner: handle errors reported by http runners #694

Closed roobre closed 2 months ago

roobre commented 2 months ago

Previously, k6 runners used to communicate errors by returning a non-200 status code, and not returning the logs of the execution. mq proxy, in addition to returning non-200 status codes, also includes an error code and description for errors that occur while running the script.

With the introduction of https://github.com/grafana/sm-k6-runner/pull/153, we now report as errors exceptions being thrown on the script, such as trying to access undefined variables, or invocations of fail(). In this scenario, users likely expect to see the check reported as a failure, but also to see the logs and metrics produced by it.

This PR changes the error-handling logic, so that the response is always parsed for status code that (should) include it, and the success of the check is calculated by checking if there response contains an error.