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

Introduce hashicorp/go-metrics compatibility #760

Merged
merged 3 commits into from
Jan 14, 2025
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
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,29 @@ Tests can be run by typing `make test`.

If you make any changes to the code, run `make format` in order to automatically
format the code according to Go [standards](https://golang.org/doc/effective_go.html#formatting).


## Metrics Emission and Compatibility

This library can emit metrics using either `github.com/armon/go-metrics` or `github.com/hashicorp/go-metrics`. Choosing between the libraries is controlled via build tags.

**Build Tags**
* `armonmetrics` - Using this tag will cause metrics to be routed to `armon/go-metrics`
* `hashicorpmetrics` - Using this tag will cause all metrics to be routed to `hashicorp/go-metrics`

If no build tag is specified, the default behavior is to use `armon/go-metrics`.

**Deprecating `armon/go-metrics`**

Emitting metrics to `armon/go-metrics` is officially deprecated. Usage of `armon/go-metrics` will remain the default until mid-2025 with opt-in support continuing to the end of 2025.

**Migration**
To migrate an application currently using the older `armon/go-metrics` to instead use `hashicorp/go-metrics` the following should be done.

1. Upgrade libraries using `armon/go-metrics` to consume `hashicorp/go-metrics/compat` instead. This should involve only changing import statements. All repositories in the `hashicorp` namespace
2. Update an applications library dependencies to those that have the compatibility layer configured.
3. Update the application to use `hashicorp/go-metrics` for configuring metrics export instead of `armon/go-metrics`
* Replace all application imports of `github.com/armon/go-metrics` with `github.com/hashicorp/go-metrics`
* Instrument your build system to build with the `hashicorpmetrics` tag.

Eventually once the default behavior changes to use `hashicorp/go-metrics` by default (mid-2025), you can drop the `hashicorpmetrics` build tag.
2 changes: 1 addition & 1 deletion cmd/serf/command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"syscall"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
gsyslog "github.com/hashicorp/go-syslog"
"github.com/hashicorp/logutils"
"github.com/hashicorp/memberlist"
Expand Down
2 changes: 1 addition & 1 deletion cmd/serf/command/agent/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"time"

"github.com/armon/circbuf"
"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
"github.com/hashicorp/serf/serf"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/serf/command/agent/ipc.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"sync/atomic"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/logutils"
"github.com/hashicorp/serf/coordinate"
Expand Down
2 changes: 1 addition & 1 deletion coordinate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"sync"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
)

// Client manages the estimated network coordinate for a given node, and adjusts
Expand Down
2 changes: 1 addition & 1 deletion coordinate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package coordinate

import (
"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
)

// Config is used to set the parameters of the Vivaldi-based coordinate mapping
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.19

require (
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e
github.com/armon/go-metrics v0.4.1
github.com/hashicorp/go-metrics v0.5.4
github.com/hashicorp/go-msgpack/v2 v2.1.2
github.com/hashicorp/go-syslog v1.0.0
github.com/hashicorp/logutils v1.0.0
github.com/hashicorp/mdns v1.0.5
github.com/hashicorp/memberlist v0.5.1
github.com/hashicorp/memberlist v0.5.2
github.com/mitchellh/cli v1.1.5
github.com/mitchellh/mapstructure v1.5.0
github.com/ryanuber/columnize v2.1.2+incompatible
Expand All @@ -19,6 +19,7 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/fatih/color v1.9.0 // indirect
Expand Down
55 changes: 53 additions & 2 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion serf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
"github.com/hashicorp/memberlist"
)

Expand Down
2 changes: 1 addition & 1 deletion serf/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"bytes"
"fmt"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/memberlist"
)
Expand Down
2 changes: 1 addition & 1 deletion serf/ping_delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"bytes"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/memberlist"
"github.com/hashicorp/serf/coordinate"
Expand Down
2 changes: 1 addition & 1 deletion serf/serf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"sync/atomic"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
"github.com/hashicorp/go-msgpack/v2/codec"
"github.com/hashicorp/memberlist"
"github.com/hashicorp/serf/coordinate"
Expand Down
2 changes: 1 addition & 1 deletion serf/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"time"

"github.com/armon/go-metrics"
"github.com/hashicorp/go-metrics/compat"
)

/*
Expand Down
Loading