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

deps: upgrade grpc-ecosystem/go-grpc-middleware to v2 and migrate to grpc-ecosystem/go-grpc-middleware/providers/prometheus #17884

Closed
wants to merge 1 commit into from

Conversation

marefr
Copy link
Contributor

@marefr marefr commented Apr 25, 2024

Upgrades github.com/grpc-ecosystem/go-grpc-middleware to v2 and migrates the deprecated github.com/grpc-ecosystem/go-grpc-prometheus to github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus.

This is my first contribution to this project and tried to follow the contribution guidelines as good as I could. Please let me know if I missed something and/or suggested changes.

Closes #17883

upgrades grpc-ecosystem/go-grpc-middleware to v2
migrates grpc-ecosystem/go-grpc-prometheus to grpc-ecosystem/go-grpc-middleware/providers/prometheus

Signed-off-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
@k8s-ci-robot
Copy link

Hi @marefr. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

grpcChainStreamList = append(grpcChainStreamList,
grpc_ctxtags.StreamServerInterceptor(),
grpc_zap.PayloadStreamServerInterceptor(lg, alwaysLoggingDeciderServer),
grpc_logging.StreamServerInterceptor(interceptorLogger(lg), opts...),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the old grpc_ctxtags.StreamServerInterceptor added a field for peer.address, https://github.com/grpc-ecosystem/go-grpc-middleware/blob/d42ae9d517069c2bd7f9339147a0eafa86b3d4a3/tags/interceptors.go#L70-L76.

The new logging interceptor adds this field as well, hence why I've removed the old grpc_ctxtags interceptors:
https://github.com/grpc-ecosystem/go-grpc-middleware/blob/7da22cf3f3d3ae190467d9c7a3ea749b3d0e63b5/interceptors/logging/interceptors.go#L168-L170

Comment on lines -821 to -823
if e.cfg.Metrics == "extensive" {
grpc_prometheus.EnableHandlingTimeHistogram()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part I struggled the most with. For now I'm passing this config down to v3rpc.Server as a string argument which doesn't feel great.

Comment on lines +47 to +49
if metrics == "extensive" {
promOpts = append(promOpts, grpc_prometheus.WithServerHandlingTimeHistogram())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This moved from server/embed/etcd.go, see the other comment.

@@ -151,3 +153,94 @@ func NewClient(t testing.TB, cfg clientv3.Config) (*clientv3.Client, error) {
}
return clientv3.New(cfg)
}

// SettableLoggerV2 is thread-safe.
type SettableLoggerV2 interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Expect this code to land in some logutil package. We have one for client client/pkg/logutil. I expect it's in client due to legacy, we could move it to pkg/logutil

@serathius
Copy link
Member

/ok-to-test

@serathius
Copy link
Member

serathius commented Apr 26, 2024

We need to make sure we don't drop or change any non-experimental metrics. Major version upgrades might come with larger changes including changes to metrics. However as user facing application we should still avoid breaking change in metrics if possible.

For this kind of PR I expect to see:

  • A list of metrics before and after the change, including names, types, labels to make sure they don't change.
  • Diff between the list if there is some differences
  • Best an e2e test that prevents a regression.

@ahrtr
Copy link
Member

ahrtr commented Apr 26, 2024

Thanks @marefr for raising this PR. Is it possible to breakdown this PR into two?

  • One is to upgrade grpc-ecosystem/go-grpc-middleware to v2
  • The other is to migrate to grpc-ecosystem/go-grpc-middleware/providers/prometheus

@marefr
Copy link
Contributor Author

marefr commented Apr 26, 2024

@ahrtr yes that sounds like a good plan 👍

@marefr
Copy link
Contributor Author

marefr commented Apr 28, 2024

I'll close this and open a new PR for upgrading grpc-ecosystem/go-grpc-middleware to v2 as a first step.

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

Successfully merging this pull request may close these issues.

Use of deprecated grpc-ecosystem/go-grpc-middleware v1 and grpc-ecosystem/go-grpc-prometheus
4 participants