Skip to content

Introduce hashicorp/go-metrics compatibility#760

Merged
mkeeler merged 3 commits intomasterfrom
metrics-compat
Jan 14, 2025
Merged

Introduce hashicorp/go-metrics compatibility#760
mkeeler merged 3 commits intomasterfrom
metrics-compat

Conversation

@mkeeler
Copy link
Member

@mkeeler mkeeler commented Dec 18, 2024

This PR migrates the library to using github.com/hashicorp/go-metrics/compat instead of github.com/armon/go-metrics.

Applications consuming the library can control whether metrics get emitted to either armon/go-metrics or hashicorp/go-metrics by specifying either the armonmetrics or hashicorpmetrics build tags. The default behavior is currently to prefer armon/go-metrics for maximum backwards compatibility.

Future PRs will:

  • Bump the hashicorp/go-metrics and hashicorp/memberlist versions to one where the default behavior is to emit metrics using hashicorp/go-metrics (Timeline: mid-2025)
  • Remove compat package usage with direct usage of hashicorp/go-metrics (Timeline: end-2025)

TODO:

  • Pull in a tagged version of hashicorp/go-metrics once upstream PR is merged
  • Pull in a tagged version of hashicorp/memberlist once upstreamPR is merged

Compatability is attained with build tags

Using tag armonmetrics or no tag at all will result in the library utilizing github.com/armon/go-metrics for metrics emission (like it has historically done)

Using tag hashicorpmetrics will result in the library utilizing the updated github.com/hashicorp/go-metrics for metrics emission.
@mkeeler mkeeler marked this pull request as ready for review January 8, 2025 19:11
@mkeeler mkeeler requested review from a team as code owners January 8, 2025 19:11
@mkeeler mkeeler requested a review from jmurret January 8, 2025 19:11
Copy link
Contributor

@mukeshjc mukeshjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mkeeler mkeeler merged commit 93c69c0 into master Jan 14, 2025
12 checks passed
@mkeeler mkeeler deleted the metrics-compat branch January 14, 2025 14:20
@RSWilli
Copy link

RSWilli commented Jan 15, 2025

How is it that armon/go-metrics is only deprecated, when you can't even install it from a fresh go mod cache? If you click on the URL: https://github.com/armon/go-metrics then you're redirected to https://github.com/hashicorp/go-metrics, which the go compiler doesn't like.

@mkeeler
Copy link
Member Author

mkeeler commented Jan 15, 2025

Maybe I should clarify the wording in the readme.

This library (and all others within the hashicorp namespace) emitting metrics to the armon/go-metrics global handler is deprecated. Right now the compatibility shim in place allows metrics to flow to either of the modules but that isn't a state we want to maintain indefinitely. Mid 2025 my plan is to flip the default behavior to prefer emitting metrics towards hashicorp/go-metrics (build tags can still opt-out). Then at the end of the year my plan is to remove the compatibility layer all together and only emit metrics to hashicorp/go-metrics.

As for using armon/go-metrics, you can still go get github.com/armon/go-metrics@v0.4.1. When Go finds this tag, the module declared in the downloaded go.mod will be armon/go-metrics and the compiler wont complain. Using, latest or any of the later versions is broken due to the module renaming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants