grafana / xk6-sql

Use SQL databases from k6 tests.
http://sql.x.k6.io
Apache License 2.0
114 stars 57 forks source link

Emit query duration metric #23

Open imiric opened 2 years ago

imiric commented 2 years ago

The extension currently doesn't emit any SQL-specific k6 metrics. A basic one that would be useful for tracking DB performance would be query_duration. It should be possible to apply thresholds and tags per query, as mentioned in #22.

While this could be implemented in JS as shown in this example, it's a very imprecise method.

Suggested solution

Golang's database/sql doesn't seem to expose any such statistics, but there's an example here that wraps driver.Driver to calculate the value. It's essentially doing what the above JS example does, but in Go, so it's not great, but it's an improvement nonetheless.