Commit Graph

15 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 dc79bd6093 Improve various comments
Signed-off-by: beorn7 <beorn@grafana.com>
2020-04-25 15:59:53 +02:00
beorn7 39dbb24d13 Add helper functions for linting to testutil
Signed-off-by: beorn7 <beorn@grafana.com>
2020-04-24 23:44:59 +02:00
Bartlomiej Plotka 9e9cc003f8 Added testutil.CollectAndCount
Signed-off-by: Bartlomiej Plotka <bwplotka@gmail.com>
2020-01-09 11:20:19 +00: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 c4c1f3461e Fix tiny punctuation issue in doc comment
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-15 18:40:33 +01:00
PhilipGough f9739b3d97
Compare text strings directly in testutil
Signed-off-by: PhilipGough <philip.p.gough@gmail.com>
2018-11-15 16:03:57 +00:00
beorn7 86702ea6b4 Fix metric comparison for empty labels
reflect.DeepEqual is not suitable for zero occurrences of repeated
proto messages. This changes the comparison to act on the string
representation of proto messages.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-11-13 16:25:02 +01:00
beorn7 74a2f46d2c Add package documentation
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-04 14:02:20 +02: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 7be86f93c1 Create an internal package
This is for types we don't want to export but which are used in
different packages within client_golang.

Currently, that's only NormalizeMetricFamilies (used in the prometheus
package and in the testutil package). More to be added as needed.

Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-09-03 00:18:11 +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 154f28a316 Fix import grouping
Signed-off-by: beorn7 <beorn@soundcloud.com>
2018-08-23 00:05:02 +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