Cut 1.20.5; update comments.

Signed-off-by: bwplotka <bwplotka@gmail.com>

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
bwplotka 2024-10-14 21:29:01 +01:00
parent 584a7ce3d9
commit 504ad9bf5c
3 changed files with 20 additions and 2 deletions

View File

@ -1,5 +1,11 @@
## Unreleased ## Unreleased
## 1.20.5 / 2024-10-15
* [BUGFIX] testutil: Reverted #1424; functions using compareMetricFamilies are (again) only failing if filtered metricNames are in the expected input.
## 1.20.4 / 2024-09-07
* [BUGFIX] histograms: Fix possible data race when appending exemplars vs metrics gather. #1623 * [BUGFIX] histograms: Fix possible data race when appending exemplars vs metrics gather. #1623
## 1.20.3 / 2024-09-05 ## 1.20.3 / 2024-09-05
@ -28,7 +34,7 @@
* [FEATURE] promlint: Add duplicated metric lint rule. #1472 * [FEATURE] promlint: Add duplicated metric lint rule. #1472
* [BUGFIX] promlint: Relax metric type in name linter rule. #1455 * [BUGFIX] promlint: Relax metric type in name linter rule. #1455
* [BUGFIX] promhttp: Make sure server instrumentation wrapping supports new and future extra responseWriter methods. #1480 * [BUGFIX] promhttp: Make sure server instrumentation wrapping supports new and future extra responseWriter methods. #1480
* [BUGFIX] testutil: Functions using compareMetricFamilies are now failing if filtered metricNames are not in the input. #1424 * [BUGFIX] **breaking** testutil: Functions using compareMetricFamilies are now failing if filtered metricNames are not in the input. #1424 (reverted in 1.20.5)
## 1.19.0 / 2024-02-27 ## 1.19.0 / 2024-02-27

View File

@ -1 +1 @@
1.20.2 1.20.5

View File

@ -158,6 +158,9 @@ func GatherAndCount(g prometheus.Gatherer, metricNames ...string) (int, error) {
// ScrapeAndCompare calls a remote exporter's endpoint which is expected to return some metrics in // ScrapeAndCompare calls a remote exporter's endpoint which is expected to return some metrics in
// plain text format. Then it compares it with the results that the `expected` would return. // plain text format. Then it compares it with the results that the `expected` would return.
// If the `metricNames` is not empty it would filter the comparison only to the given metric names. // If the `metricNames` is not empty it would filter the comparison only to the given metric names.
//
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
// both expected and scraped metrics. See https://github.com/prometheus/client_golang/issues/1351.
func ScrapeAndCompare(url string, expected io.Reader, metricNames ...string) error { func ScrapeAndCompare(url string, expected io.Reader, metricNames ...string) error {
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil { if err != nil {
@ -185,6 +188,9 @@ func ScrapeAndCompare(url string, expected io.Reader, metricNames ...string) err
// CollectAndCompare collects the metrics identified by `metricNames` and compares them in the Prometheus text // CollectAndCompare collects the metrics identified by `metricNames` and compares them in the Prometheus text
// exposition format to the data read from expected. // exposition format to the data read from expected.
//
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
// both expected and collected metrics. See https://github.com/prometheus/client_golang/issues/1351.
func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames ...string) error { func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames ...string) error {
reg := prometheus.NewPedanticRegistry() reg := prometheus.NewPedanticRegistry()
if err := reg.Register(c); err != nil { if err := reg.Register(c); err != nil {
@ -197,6 +203,9 @@ func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames .
// it to an expected output read from the provided Reader in the Prometheus text // it to an expected output read from the provided Reader in the Prometheus text
// exposition format. If any metricNames are provided, only metrics with those // exposition format. If any metricNames are provided, only metrics with those
// names are compared. // names are compared.
//
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
// both expected and gathered metrics. See https://github.com/prometheus/client_golang/issues/1351.
func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...string) error { func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...string) error {
return TransactionalGatherAndCompare(prometheus.ToTransactionalGatherer(g), expected, metricNames...) return TransactionalGatherAndCompare(prometheus.ToTransactionalGatherer(g), expected, metricNames...)
} }
@ -205,6 +214,9 @@ func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...
// it to an expected output read from the provided Reader in the Prometheus text // it to an expected output read from the provided Reader in the Prometheus text
// exposition format. If any metricNames are provided, only metrics with those // exposition format. If any metricNames are provided, only metrics with those
// names are compared. // names are compared.
//
// NOTE: Be mindful of accidental discrepancies between expected and metricNames; metricNames filter
// both expected and gathered metrics. See https://github.com/prometheus/client_golang/issues/1351.
func TransactionalGatherAndCompare(g prometheus.TransactionalGatherer, expected io.Reader, metricNames ...string) error { func TransactionalGatherAndCompare(g prometheus.TransactionalGatherer, expected io.Reader, metricNames ...string) error {
got, done, err := g.Gather() got, done, err := g.Gather()
defer done() defer done()