Skip to content

Commit 2254d6c

Browse files
authored
Merge pull request #1587 from prometheus/fix-processcollector
Fix processcollector
2 parents 73b811c + 4a15d05 commit 2254d6c

6 files changed

+17
-11
lines changed

CHANGELOG.md

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

3+
## 1.20.1 / 2024-08-20
4+
5+
* [BUGFIX] process-collector: Fixed unregistered descriptor error when using process collector with `PedanticRegistry` on linux machines. #1587
6+
37
## 1.20.0 / 2024-08-14
48

59
* [CHANGE] :warning: go-collector: Remove `go_memstat_lookups_total` metric which was always 0; Go runtime stopped sharing pointer lookup statistics. #1577
@@ -10,7 +14,7 @@
1014
* [FEATURE] promhttp: Add experimental support for `zstd` on scrape, controlled by the request `Accept-Encoding` header. #1496
1115
* [FEATURE] api/v1: Add `WithLimit` parameter to all API methods that supports it. #1544
1216
* [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
17+
* [FEATURE] process-collector: Add network usage metrics: `process_network_receive_bytes_total` and `process_network_transmit_bytes_total`. #1555
1418
* [FEATURE] promlint: Add duplicated metric lint rule. #1472
1519
* [BUGFIX] promlint: Relax metric type in name linter rule. #1455
1620
* [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.1

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
}

0 commit comments

Comments
 (0)