Skip to content

Commit 6dc2fc7

Browse files
bwplotkaamberpixels
authored andcommitted
Cut 1.20.5; update comments.
Signed-off-by: bwplotka <[email protected]> # Conflicts: # CHANGELOG.md Signed-off-by: Eugene <[email protected]>
1 parent 523cb21 commit 6dc2fc7

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Unreleased
22

3+
## 1.20.5 / 2024-10-15
4+
5+
* [BUGFIX] testutil: Reverted #1424; functions using compareMetricFamilies are (again) only failing if filtered metricNames are in the expected input.
6+
7+
## 1.20.4 / 2024-09-07
8+
39
* [BUGFIX] histograms: Fix possible data race when appending exemplars vs metrics gather. #1623
410

511
## 1.20.3 / 2024-09-05
@@ -28,7 +34,7 @@
2834
* [FEATURE] promlint: Add duplicated metric lint rule. #1472
2935
* [BUGFIX] promlint: Relax metric type in name linter rule. #1455
3036
* [BUGFIX] promhttp: Make sure server instrumentation wrapping supports new and future extra responseWriter methods. #1480
31-
* [BUGFIX] testutil: Functions using compareMetricFamilies are now failing if filtered metricNames are not in the input. #1424
37+
* [BUGFIX] **breaking** testutil: Functions using compareMetricFamilies are now failing if filtered metricNames are not in the input. #1424 (reverted in 1.20.5)
3238

3339
## 1.19.0 / 2024-02-27
3440

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.20.2
1+
1.20.5

prometheus/testutil/testutil.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ func GatherAndCount(g prometheus.Gatherer, metricNames ...string) (int, error) {
160160
// ScrapeAndCompare calls a remote exporter's endpoint which is expected to return some metrics in
161161
// plain text format. Then it compares it with the results that the `expected` would return.
162162
// If the `metricNames` is not empty it would filter the comparison only to the given metric names.
163+
//
164+
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
165+
// both expected and scraped metrics. See https://github.com/prometheus/client_golang/issues/1351.
163166
func ScrapeAndCompare(url string, expected io.Reader, metricNames ...string) error {
164167
resp, err := http.Get(url)
165168
if err != nil {
@@ -187,6 +190,9 @@ func ScrapeAndCompare(url string, expected io.Reader, metricNames ...string) err
187190

188191
// CollectAndCompare collects the metrics identified by `metricNames` and compares them in the Prometheus text
189192
// exposition format to the data read from expected.
193+
//
194+
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
195+
// both expected and collected metrics. See https://github.com/prometheus/client_golang/issues/1351.
190196
func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames ...string) error {
191197
reg := prometheus.NewPedanticRegistry()
192198
if err := reg.Register(c); err != nil {
@@ -199,6 +205,9 @@ func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames .
199205
// it to an expected output read from the provided Reader in the Prometheus text
200206
// exposition format. If any metricNames are provided, only metrics with those
201207
// names are compared.
208+
//
209+
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
210+
// both expected and gathered metrics. See https://github.com/prometheus/client_golang/issues/1351.
202211
func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...string) error {
203212
return TransactionalGatherAndCompare(prometheus.ToTransactionalGatherer(g), expected, metricNames...)
204213
}
@@ -207,6 +216,9 @@ func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...
207216
// it to an expected output read from the provided Reader in the Prometheus text
208217
// exposition format. If any metricNames are provided, only metrics with those
209218
// names are compared.
219+
//
220+
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
221+
// both expected and gathered metrics. See https://github.com/prometheus/client_golang/issues/1351.
210222
func TransactionalGatherAndCompare(g prometheus.TransactionalGatherer, expected io.Reader, metricNames ...string) error {
211223
got, done, err := g.Gather()
212224
defer done()

0 commit comments

Comments
 (0)