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

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

@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/[email protected]. 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