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

chore: armon/go-metrics => hashicorp/go-metrics #24268

Conversation

peteski22
Copy link

@peteski22 peteski22 commented Nov 28, 2023

This PR is intended to remove the direct dependency within Vault on armon/go-metrics in favor of hashicorp/go-metrics. This should make life easier when we want to update versions going foward.

In addition it also bumps the version to 0.5.3 based on hashicorp/go-metrics#146.

Using go mod graph | grep ' github.com/armon/go-metrics@v\d.\d.\d$' we can identify indirect dependencies on armon/go-metrics in other packages used by Vault, which may require their own PRs if they decide to move away from the library. It would be worth checking each package repo to see if they have tagged newer versions which have already moved to hashicorp/go-metrics and then update Vault to reference them.

github.com/hashicorp/vault github.com/armon/[email protected]
github.com/google/tink/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/consul/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]
github.com/hashicorp/[email protected] github.com/armon/[email protected]

…cs to hashicorp/go-metrics and bumped to version 0.5.3
@peteski22 peteski22 added dependencies Pull requests that update a dependency file hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed labels Nov 28, 2023
@@ -97,6 +96,7 @@ require (
github.com/hashicorp/go-kms-wrapping/wrappers/ocikms/v2 v2.0.7
github.com/hashicorp/go-kms-wrapping/wrappers/transit/v2 v2.0.8
github.com/hashicorp/go-memdb v1.3.4
github.com/hashicorp/go-metrics v0.5.3
Copy link
Author

Choose a reason for hiding this comment

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

Version bump: 0.5.1 (indirect) => 0.5.3 (direct)

@@ -73,7 +72,7 @@ require (
github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6
github.com/google/go-cmp v0.5.9
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-metrics-stackdriver v0.2.0
github.com/google/go-metrics-stackdriver v0.6.0
Copy link
Author

Choose a reason for hiding this comment

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

Version bump: 0.2.0 => 0.6.0

"github.com/armon/go-metrics/circonus"
"github.com/armon/go-metrics/datadog"
"github.com/armon/go-metrics/prometheus"
monitoring "cloud.google.com/go/monitoring/apiv3/v2"
Copy link
Author

Choose a reason for hiding this comment

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

Using v2 now.

@@ -23,6 +22,7 @@ require (
github.com/hashicorp/go-immutable-radix v1.3.1
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0
github.com/hashicorp/go-kms-wrapping/v2 v2.0.8
github.com/hashicorp/go-metrics v0.5.3
Copy link
Author

Choose a reason for hiding this comment

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

Moved SDK dependency armon/go-metrics to hashicorp/go-metrics and bumped 0.4.1 => 0.5.3

@peteski22 peteski22 requested a review from a team November 28, 2023 11:29
@peteski22 peteski22 added this to the 1.15.4 milestone Nov 28, 2023
Copy link

github-actions bot commented Nov 28, 2023

CI Results:
All Go tests succeeded! ✅

@@ -1828,6 +1828,7 @@ listener "tcp" {
"Samples",
"Timestamp",
"Gauges",
"PrecisionGauges",
Copy link
Author

Choose a reason for hiding this comment

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

@@ -2660,6 +2660,7 @@ listener "tcp" {
"Samples",
"Timestamp",
"Gauges",
"PrecisionGauges",
Copy link
Author

Choose a reason for hiding this comment

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

@peteski22 peteski22 changed the title armon/go-metrics => hashicorp/go-metrics chore: armon/go-metrics => hashicorp/go-metrics Nov 28, 2023
@peteski22 peteski22 marked this pull request as ready for review November 28, 2023 12:06
@peteski22 peteski22 requested review from a team as code owners November 28, 2023 12:06
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

Great job Pete!

Thinking this through... I'm pretty sure this is going to break a lot of things related to metrics due to the (unfortunate IMO) design choices in go-metrics.

The fact that metrics uses global state to setup sinks and instrumentation means that if any libraries are still using the armon version, those metrics are suddenly going to dissapear from Vault's actual metrics collection which will now be using hashicorp right?

At first I thought we'd need to go and fix every one of those deps you listed before we can merge, but actually I think it would be sufficient to also add a

replace github.com/armon/go-metrics => github.com/hashicorp/go-metrics 

Bit we'd need to verify this - it would be great to build before and after this PR and verify that all those library's metrics (e.g. Raft metrics) are still present! It's complicated further by the fact that only metrics reported recently are actually output (anther design issues 😢 ) so it's not trivial to just start vault and hit the metrics endpoint once - we may need to actually ensure things happen to see the metrics. The good news is that as long as we have one metric from each library in your list (that currently outputs metrics) that's OK we don't need to figure out how to trigger every single metric to be output!

@peteski22 peteski22 requested review from a team November 28, 2023 12:07
@peteski22
Copy link
Author

peteski22 commented Nov 28, 2023

Great job Pete!

Thinking this through... I'm pretty sure this is going to break a lot of things related to metrics due to the (unfortunate IMO) design choices in go-metrics.

The fact that metrics uses global state to setup sinks and instrumentation means that if any libraries are still using the armon version, those metrics are suddenly going to dissapear from Vault's actual metrics collection which will now be using hashicorp right?

At first I thought we'd need to go and fix every one of those deps you listed before we can merge, but actually I think it would be sufficient to also add a

replace github.com/armon/go-metrics => github.com/hashicorp/go-metrics 

Bit we'd need to verify this - it would be great to build before and after this PR and verify that all those library's metrics (e.g. Raft metrics) are still present! It's complicated further by the fact that only metrics reported recently are actually output (anther design issues 😢 ) so it's not trivial to just start vault and hit the metrics endpoint once - we may need to actually ensure things happen to see the metrics. The good news is that as long as we have one metric from each library in your list (that currently outputs metrics) that's OK we don't need to figure out how to trigger every single metric to be output!

Blimey that was fast. 😄

Would the problem of global state not have existed previously since we had the indirect reference to hashicorp/go-metrics (so something down the stack was using it)? 🤔

Good shout on adding the replace, I'll push that up now.

Sad about the amount of testing we'd require to be OK with this though, eeek.

Copy link

github-actions bot commented Nov 28, 2023

Build Results:
All builds succeeded! ✅

@biazmoreira
Copy link
Contributor

Closing #21130

@biazmoreira
Copy link
Contributor

@peteski22

It's complicated further by the fact that only metrics reported recently are actually output (anther design issues 😢 ) so it's not trivial to just start vault and hit the metrics endpoint once - we may need to actually ensure things happen to see the metrics.

One idea is to use an HCPV cluster with a custom binary to test this out. There's an amount of work required to enable the observability provider and so on, but not sure how you plan on testing this. In any case, I'm excited to see this finally being done!

@banks
Copy link
Member

banks commented Nov 28, 2023

Would the problem of global state not have existed previously...

I've realised I'm probably wrong here since we actually renamed the repo anyway. I was thinking theyd import as differnt modules but actually since we renamed/redirected and updated to go.mod, I think both paths will end up importing the same module under the declared name hashicorp/go-metrics.

But yeah we should double check that - e.g. that library metrics are still being emitted. If they are then I think this is fine and we don't need a huge effort to check every single library since they will all work the same way!

That probable means the replace directive is unnecessary too?

Sorry for the noise!

@peteski22 peteski22 force-pushed the peteski22/dependency/swap-armon-go-metrics-to-hashicorp-go-metrics branch from 8dc9738 to 7808f4c Compare November 28, 2023 14:12
…swap-armon-go-metrics-to-hashicorp-go-metrics
…swap-armon-go-metrics-to-hashicorp-go-metrics
…swap-armon-go-metrics-to-hashicorp-go-metrics
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

I've realised I'm probably wrong

Wrong again!

Actually this was a legitimate concern that we have now confirmed and that Nomad also discovered independently.

The issue is that despite the redirect which makes it appear to work fine if you mix armon/ and hashicorp/ imports in a greenfield project, all our products (and other projects no doubt that use our libraries) are currently pinned to a version of go-metrics from before 0.5.0 where the module name was changed.

That means that although the import redirects to hashicorp/ to fetch the code, it's checking out a version of the module whose go.mod still calls itself armon/go-metrics.

That results in Consul, Vault and Nomad setting up and configuring metrics syncs on the armon flavour global metrics instance, while any dependencies that happen to import hashicorp/go-metrics would likely end up on a newer version that calls itslef hashicorp/go-metrics and so their metrics will be reported to a different singleton instance than the one that we are actually outputting from and their metrics will be lost!

Conversely, if any of our products change imports and/or upgrade go-metrics to 0.5.0 or higher, we will loose all the metrics being reported to the older armon/go-metrics import.

There may be some way out of this cleanly but a few folks have looked and it's seeming like a v2 of all our libs will be needed to make the breaking change necessary potentially.

So much as I'd love to resolve this.... this PR should be held back until we work out the strategy across all our products!

@peteski22 peteski22 marked this pull request as draft January 9, 2024 18:23
…swap-armon-go-metrics-to-hashicorp-go-metrics
@ldilalla-HC ldilalla-HC removed this from the 1.15.5 milestone Jan 26, 2024
@peteski22 peteski22 closed this Mar 4, 2024
@peteski22 peteski22 deleted the peteski22/dependency/swap-armon-go-metrics-to-hashicorp-go-metrics branch August 16, 2024 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file do-not-merge hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants