Merge pull request #1587 from prometheus/fix-processcollector

Fix processcollector
This commit is contained in:
Arthur Silva Sens 2024-08-20 08:43:51 -03:00 committed by GitHub
commit 2254d6c308
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,9 @@
## Unreleased ## Unreleased
## 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 ## 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 * [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 @@
* [FEATURE] promhttp: Add experimental support for `zstd` on scrape, controlled by the request `Accept-Encoding` header. #1496 * [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] 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] 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 * [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

View File

@ -1 +1 @@
1.20.0 1.20.1

View File

@ -21,7 +21,7 @@ import (
) )
func TestDBStatsCollector(t *testing.T) { func TestDBStatsCollector(t *testing.T) {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
{ {
db := new(sql.DB) db := new(sql.DB)
if err := reg.Register(NewDBStatsCollector(db, "db_A")); err != nil { if err := reg.Register(NewDBStatsCollector(db, "db_A")); err != nil {

View File

@ -63,7 +63,7 @@ var memstatMetrics = []string{
} }
func TestGoCollectorMarshalling(t *testing.T) { func TestGoCollectorMarshalling(t *testing.T) {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector( reg.MustRegister(NewGoCollector(
WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{ WithGoCollectorRuntimeMetrics(GoRuntimeMetricsRule{
Matcher: regexp.MustCompile("/.*"), Matcher: regexp.MustCompile("/.*"),
@ -80,7 +80,7 @@ func TestGoCollectorMarshalling(t *testing.T) {
} }
func TestWithGoCollectorDefault(t *testing.T) { func TestWithGoCollectorDefault(t *testing.T) {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector()) reg.MustRegister(NewGoCollector())
result, err := reg.Gather() result, err := reg.Gather()
if err != nil { if err != nil {
@ -100,7 +100,7 @@ func TestWithGoCollectorDefault(t *testing.T) {
} }
func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) { func TestWithGoCollectorMemStatsMetricsDisabled(t *testing.T) {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector( reg.MustRegister(NewGoCollector(
WithGoCollectorMemStatsMetricsDisabled(), WithGoCollectorMemStatsMetricsDisabled(),
)) ))
@ -157,7 +157,7 @@ func TestGoCollectorAllowList(t *testing.T) {
}, },
} { } {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector( reg.MustRegister(NewGoCollector(
WithGoCollectorMemStatsMetricsDisabled(), WithGoCollectorMemStatsMetricsDisabled(),
WithGoCollectorRuntimeMetrics(test.rules...), WithGoCollectorRuntimeMetrics(test.rules...),
@ -219,7 +219,7 @@ func TestGoCollectorDenyList(t *testing.T) {
}, },
} { } {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
reg.MustRegister(NewGoCollector( reg.MustRegister(NewGoCollector(
WithGoCollectorMemStatsMetricsDisabled(), WithGoCollectorMemStatsMetricsDisabled(),
WithoutGoCollectorRuntimeMetrics(test.matchers...), WithoutGoCollectorRuntimeMetrics(test.matchers...),
@ -242,7 +242,7 @@ func TestGoCollectorDenyList(t *testing.T) {
} }
func ExampleGoCollector() { 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. // Register the GoCollector with the default options. Only the base metrics, default runtime metrics and memstats are enabled.
reg.MustRegister(NewGoCollector()) reg.MustRegister(NewGoCollector())
@ -252,7 +252,7 @@ func ExampleGoCollector() {
} }
func ExampleGoCollector_WithAdvancedGoMetrics() { func ExampleGoCollector_WithAdvancedGoMetrics() {
reg := prometheus.NewRegistry() reg := prometheus.NewPedanticRegistry()
// Enable Go metrics with pre-defined rules. Or your custom rules. // Enable Go metrics with pre-defined rules. Or your custom rules.
reg.MustRegister( reg.MustRegister(

View File

@ -140,6 +140,8 @@ func (c *processCollector) Describe(ch chan<- *Desc) {
ch <- c.maxVsize ch <- c.maxVsize
ch <- c.rss ch <- c.rss
ch <- c.startTime ch <- c.startTime
ch <- c.inBytes
ch <- c.outBytes
} }
// Collect returns the current state of all metrics of the collector. // Collect returns the current state of all metrics of the collector.

View File

@ -37,7 +37,7 @@ func TestProcessCollector(t *testing.T) {
t.Skipf("skipping TestProcessCollector, procfs not available: %s", err) t.Skipf("skipping TestProcessCollector, procfs not available: %s", err)
} }
registry := NewRegistry() registry := NewPedanticRegistry()
if err := registry.Register(NewProcessCollector(ProcessCollectorOpts{})); err != nil { if err := registry.Register(NewProcessCollector(ProcessCollectorOpts{})); err != nil {
t.Fatal(err) t.Fatal(err)
} }