Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release-1.20 back to main #1593

Merged
merged 8 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Unreleased

## 1.20.2 / 2024-08-23

* [BUGFIX] promhttp: Unset Content-Encoding header when data is uncompressed. #1596

## 1.20.1 / 2024-08-20

* [BUGFIX] process-collector: Fixed unregistered descriptor error when using process collector with `PedanticRegistry` on linux machines. #1587

## 1.20.0 / 2024-08-14

* [CHANGE] :warning: go-collector: Remove `go_memstat_lookups_total` metric which was always 0; Go runtime stopped sharing pointer lookup statistics. #1577
Expand All @@ -10,7 +18,7 @@
* [FEATURE] promhttp: Add experimental support for `zstd` on scrape, controlled by the request `Accept-Encoding` header. #1496
* [FEATURE] api/v1: Add `WithLimit` parameter to all API methods that supports it. #1544
* [FEATURE] prometheus: Add support for created timestamps in constant histograms and constant summaries. #1537
* [FEATURE] process-collectors: Add network usage metrics: `process_network_receive_bytes_total` and `process_network_transmit_bytes_total`. #1555
* [FEATURE] process-collector: Add network usage metrics: `process_network_receive_bytes_total` and `process_network_transmit_bytes_total`. #1555
* [FEATURE] promlint: Add duplicated metric lint rule. #1472
* [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
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.20.0
1.20.2
2 changes: 1 addition & 1 deletion prometheus/collectors/dbstats_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestDBStatsCollector(t *testing.T) {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()
{
db := new(sql.DB)
if err := reg.Register(NewDBStatsCollector(db, "db_A")); err != nil {
Expand Down
14 changes: 7 additions & 7 deletions prometheus/collectors/go_collector_latest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var memstatMetrics = []string{
}

func TestGoCollectorMarshalling(t *testing.T) {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector(
WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{
Matcher: regexp.MustCompile("/.*"),
Expand All @@ -80,7 +80,7 @@ func TestGoCollectorMarshalling(t *testing.T) {
}

func TestWithGoCollectorDefault(t *testing.T) {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector())
result, err := reg.Gather()
if err != nil {
Expand All @@ -100,7 +100,7 @@ func TestWithGoCollectorDefault(t *testing.T) {
}

func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector(
WithGoCollectorMemStatsMetricsDisabled(),
))
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestGoCollectorAllowList(t *testing.T) {
},
} {
t.Run(test.name, func(t *testing.T) {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector(
WithGoCollectorMemStatsMetricsDisabled(),
WithGoCollectorRuntimeMetrics(test.rules...),
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestGoCollectorDenyList(t *testing.T) {
},
} {
t.Run(test.name, func(t *testing.T) {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector(
WithGoCollectorMemStatsMetricsDisabled(),
WithoutGoCollectorRuntimeMetrics(test.matchers...),
Expand All @@ -242,7 +242,7 @@ func TestGoCollectorDenyList(t *testing.T) {
}

func ExampleGoCollector() {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()

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

func ExampleGoCollector_WithAdvancedGoMetrics() {
reg := prometheus.NewRegistry()
reg := prometheus.NewPedanticRegistry()

// Enable Go metrics with pre-defined rules. Or your custom rules.
reg.MustRegister(
Expand Down
2 changes: 2 additions & 0 deletions prometheus/process_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
ch <- c.maxVsize
ch <- c.rss
ch <- c.startTime
ch <- c.inBytes
ch <- c.outBytes
}

// Collect returns the current state of all metrics of the collector.
Expand Down
2 changes: 1 addition & 1 deletion prometheus/process_collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestProcessCollector(t *testing.T) {
t.Skipf("skipping TestProcessCollector, procfs not available: %s", err)
}

registry := NewRegistry()
registry := NewPedanticRegistry()
if err := registry.Register(NewProcessCollector(ProcessCollectorOpts{})); err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 4 additions & 2 deletions prometheus/promhttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,10 @@ func HandlerForTransactional(reg prometheus.TransactionalGatherer, opts HandlerO

defer closeWriter()

rsp.Header().Set(contentEncodingHeader, encodingHeader)

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

// handleError handles the error according to opts.ErrorHandling
Expand Down
2 changes: 1 addition & 1 deletion prometheus/promhttp/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func TestInstrumentMetricHandler(t *testing.T) {
t.Errorf("got HTTP status code %d, want %d", got, want)
}

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

Expand Down