Commit Graph

10 Commits

Author SHA1 Message Date
beorn7 0577ef6c57 Improve CollectAndCount
Now that we have also added CollectAndLint and GatherAndLint, I
thought we should bring CollectAndCount in line. So:

- Add GatherAndCount.
- Add filtering by metric name.
- Add tests.

Minor wart: CollectAndCount should now return `(int, error)`, but that
would be a breaking change as the current version just returns
`int`. I decided to let the new version panic when it should return an
error. An error is anyway very unlikely, so the biggest annoyance here
is really just the inconsistency.

Signed-off-by: beorn7 <beorn@grafana.com>
2020-05-14 00:17:45 +02:00
beorn7 8785922956 Revert "Fix tests to adhere to the recent change in prometheus/common"
This reverts commit 2c9811f88e.

This is necessary because the changes in prometheus/common got reverted.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-01-27 23:18:44 +01:00
beorn7 b3d6096432 Improve testutil error messages
This also satisfy newer staticcheck versions.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2019-01-06 00:22:03 +01:00
beorn7 2c9811f88e Fix tests to adhere to the recent change in prometheus/common
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-12-18 17:20:25 +01:00
PhilipGough 30503fe98e
Exposes bug #498 - unexpected results for Histograms in testutil
Signed-off-by: PhilipGough <philip.p.gough@gmail.com>
2018-11-14 11:58:43 +00:00
beorn7 1db43792db Expose bug #494
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-13 15:48:48 +01:00
beorn7 1301cf8fcd Add helper function to extract a simple float value from a metric
Signed-off-by: beorn7 <beorn@soundcloud.com>

foo
2018-09-04 14:02:19 +02:00
beorn7 5ba0993f6f Improved interface
- Expected text format is now read from an io.Reader.
- Metrics are gathered from a Gatherer.
- Added a convenience wrapper to collect from a Collector.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-02 21:07:38 +02:00
beorn7 e60f998e9b Make license headers consistent
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-22 23:59:40 +02:00
beorn7 df0210c26c Rename testutils to testutil and move below prometheus dir
`testutil` is more in line with stdlib naming conventions.

The package should be below `prometheus` as it only provides utils to
test exposition code, not to test HTTP client code.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-22 23:57:08 +02:00