Skip to content

Commit f5a27ec

Browse files
authored
Expose more Go runtime metrics (#7070)
* expose more Go runtime metrics Signed-off-by: yeya24 <benye@amazon.com> * changelog Signed-off-by: yeya24 <benye@amazon.com> --------- Signed-off-by: yeya24 <benye@amazon.com>
1 parent 3c6603d commit f5a27ec

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
* [ENHANCEMENT] Add source metadata to requests(api vs ruler) #6947
8484
* [ENHANCEMENT] Add new metric `cortex_discarded_series` and `cortex_discarded_series_per_labelset` to track number of series that have a discarded sample. #6995
8585
* [ENHANCEMENT] Ingester: Add `cortex_ingester_tsdb_head_stale_series` metric to keep track of number of stale series on head. #7071
86+
* [ENHANCEMENT] Expose more Go runtime metrics. #7070
8687
* [BUGFIX] Ingester: Avoid error or early throttling when READONLY ingesters are present in the ring #6517
8788
* [BUGFIX] Ingester: Fix labelset data race condition. #6573
8889
* [BUGFIX] Compactor: Cleaner should not put deletion marker for blocks with no-compact marker. #6576

cmd/cortex/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"math/rand"
1010
"os"
11+
"regexp"
1112
"runtime"
1213
"sort"
1314
"strings"
@@ -16,6 +17,7 @@ import (
1617
"github.com/go-kit/log/level"
1718
"github.com/pkg/errors"
1819
"github.com/prometheus/client_golang/prometheus"
20+
"github.com/prometheus/client_golang/prometheus/collectors"
1921
collectorversion "github.com/prometheus/client_golang/prometheus/collectors/version"
2022
"github.com/prometheus/common/version"
2123
_ "go.uber.org/automaxprocs"
@@ -146,6 +148,20 @@ func main() {
146148
return
147149
}
148150

151+
// https://github.com/prometheus/prometheus/blob/release-3.7/cmd/prometheus/main.go#L331
152+
// Unregister the default GoCollector, and reregister with our defaults.
153+
if prometheus.Unregister(collectors.NewGoCollector()) {
154+
prometheus.MustRegister(
155+
collectors.NewGoCollector(
156+
collectors.WithGoCollectorRuntimeMetrics(
157+
collectors.MetricsGC,
158+
collectors.MetricsScheduler,
159+
collectors.GoRuntimeMetricsRule{Matcher: regexp.MustCompile(`^/sync/mutex/wait/total:seconds$`)},
160+
),
161+
),
162+
)
163+
}
164+
149165
if mutexProfileFraction > 0 {
150166
runtime.SetMutexProfileFraction(mutexProfileFraction)
151167
}

0 commit comments

Comments
 (0)