Skip to content

Commit dbf72fc

Browse files
authored
Merge pull request prometheus#1593 from prometheus/release-1.20
Merge release-1.20 back to main
2 parents b5361fe + 67121dc commit dbf72fc

8 files changed

+26
-14
lines changed

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## Unreleased
22

3+
## 1.20.2 / 2024-08-23
4+
5+
* [BUGFIX] promhttp: Unset Content-Encoding header when data is uncompressed. #1596
6+
7+
## 1.20.1 / 2024-08-20
8+
9+
* [BUGFIX] process-collector: Fixed unregistered descriptor error when using process collector with `PedanticRegistry` on linux machines. #1587
10+
311
## 1.20.0 / 2024-08-14
412

513
* [CHANGE] :warning: go-collector: Remove `go_memstat_lookups_total` metric which was always 0; Go runtime stopped sharing pointer lookup statistics. #1577
@@ -10,7 +18,7 @@
1018
* [FEATURE] promhttp: Add experimental support for `zstd` on scrape, controlled by the request `Accept-Encoding` header. #1496
1119
* [FEATURE] api/v1: Add `WithLimit` parameter to all API methods that supports it. #1544
1220
* [FEATURE] prometheus: Add support for created timestamps in constant histograms and constant summaries. #1537
13-
* [FEATURE] process-collectors: Add network usage metrics: `process_network_receive_bytes_total` and `process_network_transmit_bytes_total`. #1555
21+
* [FEATURE] process-collector: Add network usage metrics: `process_network_receive_bytes_total` and `process_network_transmit_bytes_total`. #1555
1422
* [FEATURE] promlint: Add duplicated metric lint rule. #1472
1523
* [BUGFIX] promlint: Relax metric type in name linter rule. #1455
1624
* [BUGFIX] promhttp: Make sure server instrumentation wrapping supports new and future extra responseWriter methods. #1480

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.20.0
1+
1.20.2

prometheus/collectors/dbstats_collector_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
func TestDBStatsCollector(t *testing.T) {
24-
reg := prometheus.NewRegistry()
24+
reg := prometheus.NewPedanticRegistry()
2525
{
2626
db := new(sql.DB)
2727
if err := reg.Register(NewDBStatsCollector(db, "db_A")); err != nil {

prometheus/collectors/go_collector_latest_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var memstatMetrics = []string{
6363
}
6464

6565
func TestGoCollectorMarshalling(t *testing.T) {
66-
reg := prometheus.NewRegistry()
66+
reg := prometheus.NewPedanticRegistry()
6767
reg.MustRegister(NewGoCollector(
6868
WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{
6969
Matcher: regexp.MustCompile("/.*"),
@@ -80,7 +80,7 @@ func TestGoCollectorMarshalling(t *testing.T) {
8080
}
8181

8282
func TestWithGoCollectorDefault(t *testing.T) {
83-
reg := prometheus.NewRegistry()
83+
reg := prometheus.NewPedanticRegistry()
8484
reg.MustRegister(NewGoCollector())
8585
result, err := reg.Gather()
8686
if err != nil {
@@ -100,7 +100,7 @@ func TestWithGoCollectorDefault(t *testing.T) {
100100
}
101101

102102
func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) {
103-
reg := prometheus.NewRegistry()
103+
reg := prometheus.NewPedanticRegistry()
104104
reg.MustRegister(NewGoCollector(
105105
WithGoCollectorMemStatsMetricsDisabled(),
106106
))
@@ -157,7 +157,7 @@ func TestGoCollectorAllowList(t *testing.T) {
157157
},
158158
} {
159159
t.Run(test.name, func(t *testing.T) {
160-
reg := prometheus.NewRegistry()
160+
reg := prometheus.NewPedanticRegistry()
161161
reg.MustRegister(NewGoCollector(
162162
WithGoCollectorMemStatsMetricsDisabled(),
163163
WithGoCollectorRuntimeMetrics(test.rules...),
@@ -219,7 +219,7 @@ func TestGoCollectorDenyList(t *testing.T) {
219219
},
220220
} {
221221
t.Run(test.name, func(t *testing.T) {
222-
reg := prometheus.NewRegistry()
222+
reg := prometheus.NewPedanticRegistry()
223223
reg.MustRegister(NewGoCollector(
224224
WithGoCollectorMemStatsMetricsDisabled(),
225225
WithoutGoCollectorRuntimeMetrics(test.matchers...),
@@ -242,7 +242,7 @@ func TestGoCollectorDenyList(t *testing.T) {
242242
}
243243

244244
func ExampleGoCollector() {
245-
reg := prometheus.NewRegistry()
245+
reg := prometheus.NewPedanticRegistry()
246246

247247
// Register the GoCollector with the default options. Only the base metrics, default runtime metrics and memstats are enabled.
248248
reg.MustRegister(NewGoCollector())
@@ -252,7 +252,7 @@ func ExampleGoCollector() {
252252
}
253253

254254
func ExampleGoCollector_WithAdvancedGoMetrics() {
255-
reg := prometheus.NewRegistry()
255+
reg := prometheus.NewPedanticRegistry()
256256

257257
// Enable Go metrics with pre-defined rules. Or your custom rules.
258258
reg.MustRegister(

prometheus/process_collector.go

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
140140
ch <- c.maxVsize
141141
ch <- c.rss
142142
ch <- c.startTime
143+
ch <- c.inBytes
144+
ch <- c.outBytes
143145
}
144146

145147
// Collect returns the current state of all metrics of the collector.

prometheus/process_collector_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestProcessCollector(t *testing.T) {
3737
t.Skipf("skipping TestProcessCollector, procfs not available: %s", err)
3838
}
3939

40-
registry := NewRegistry()
40+
registry := NewPedanticRegistry()
4141
if err := registry.Register(NewProcessCollector(ProcessCollectorOpts{})); err != nil {
4242
t.Fatal(err)
4343
}

prometheus/promhttp/http.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO
203203

204204
defer closeWriter()
205205

206-
rsp.Header().Set(contentEncodingHeader, encodingHeader)
207-
206+
// Set Content-Encoding only when data is compressed
207+
if encodingHeader != string(Identity) {
208+
rsp.Header().Set(contentEncodingHeader, encodingHeader)
209+
}
208210
enc := expfmt.NewEncoder(w, contentType)
209211

210212
// handleError handles the error according to opts.ErrorHandling

prometheus/promhttp/http_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func TestInstrumentMetricHandler(t *testing.T) {
267267
t.Errorf("got HTTP status code %d, want %d", got, want)
268268
}
269269

270-
if got, want := writer.Header().Get(contentEncodingHeader), string(Identity); got != want {
270+
if got, want := writer.Header().Get(contentEncodingHeader), ""; got != want {
271271
t.Errorf("got HTTP content encoding header %s, want %s", got, want)
272272
}
273273

0 commit comments

Comments
 (0)