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

Upgrade to github.com/hashicorp/go-metrics #362

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.20
require (
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
github.com/alicebob/miniredis v2.5.0+incompatible
github.com/armon/go-metrics v0.3.10
github.com/aws/aws-sdk-go v1.44.321
github.com/cespare/xxhash v1.1.0
github.com/cristalhq/hedgedhttp v0.9.1
Expand All @@ -23,6 +22,7 @@ require (
github.com/grafana/gomemcache v0.0.0-20231023152154-6947259a0586
github.com/hashicorp/consul/api v1.15.3
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-metrics v0.5.1
github.com/hashicorp/go-sockaddr v1.0.2
github.com/hashicorp/golang-lru/v2 v2.0.5
github.com/hashicorp/memberlist v0.3.1
Expand Down Expand Up @@ -58,6 +58,7 @@ require (
require (
github.com/OneOfOne/xxhash v1.2.6 // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE=
github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-metrics v0.5.1 h1:rfPwUqFU6uZXNvGl4hzjY8LEBsqFVU4si1H9/Hqck/U=
github.com/hashicorp/go-metrics v0.5.1/go.mod h1:KEjodfebIOuBYSAe/bHTm+HChmKSxAOXPBieMLYozDE=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI=
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
Expand Down
16 changes: 8 additions & 8 deletions kv/memberlist/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package memberlist
import (
"time"

armonmetrics "github.com/armon/go-metrics"
armonprometheus "github.com/armon/go-metrics/prometheus"
"github.com/go-kit/log/level"
"github.com/hashicorp/go-metrics"
hashiprometheus "github.com/hashicorp/go-metrics/prometheus"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

Expand Down Expand Up @@ -177,24 +177,24 @@ func (m *KV) createAndRegisterMetrics() {

m.registerer.MustRegister(m)

// memberlist uses armonmetrics package for internal usage
// here we configure armonmetrics to use prometheus.
opts := armonprometheus.PrometheusOpts{
// memberlist uses metrics package for internal usage
// here we configure metrics to use prometheus.
opts := hashiprometheus.PrometheusOpts{
Expiration: 0, // Don't expire metrics.
Registerer: m.registerer,
}

sink, err := armonprometheus.NewPrometheusSinkFrom(opts)
sink, err := hashiprometheus.NewPrometheusSinkFrom(opts)
if err == nil {
cfg := armonmetrics.DefaultConfig("")
cfg := metrics.DefaultConfig("")
cfg.EnableHostname = false // no need to put hostname into metric
cfg.EnableHostnameLabel = false // no need to put hostname into labels
cfg.EnableServiceLabel = false // Don't put service name into a label. (We don't set service name anyway).
cfg.EnableRuntimeMetrics = false // metrics about Go runtime already provided by prometheus
cfg.EnableTypePrefix = true // to make better sense of internal memberlist metrics
cfg.TimerGranularity = time.Second // timers are in seconds in prometheus world

_, err = armonmetrics.NewGlobal(cfg, sink)
_, err = metrics.NewGlobal(cfg, sink)
}

if err != nil {
Expand Down