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

Change client dialOpts append order #11322

Merged
merged 9 commits into from
Mar 24, 2022
Merged

Conversation

rcanderson23
Copy link
Contributor

@rcanderson23 rcanderson23 commented Mar 21, 2022

Any dialOpts that are provided in the config but collide with what we set in dialGRPC() will be overridden. This change allows any config options to take precedent.

Example client snippet:

	var dialOpts []grpc.DialOption
	unary := mw.ChainUnaryClient(metadata.UnaryClientInterceptor, om.UnaryClientInterceptor(grpcMetrics))
	stream := mw.ChainStreamClient(metadata.StreamClientInterceptor, om.StreamClientInterceptor(grpcMetrics))

	dialOpts = append(dialOpts, grpc.WithUnaryInterceptor(unary), grpc.WithChainStreamInterceptor(stream))

	clt, err := client.New(ctx, client.Config{
		Addrs: []string{
			"teleport.carsonanderson.net:3025",
		},
		Credentials: []client.Credentials{
			client.LoadIdentityFile("teleport-auth.pem"),
		},
		DialOpts: dialOpts,
	})

Prior to this change, you wouldn't be able to setup a client and get grpc metrics with it (or any additional client interceptors).

The end goal is to get grpc client metrics on the proxy.

@rcanderson23 rcanderson23 marked this pull request as ready for review March 21, 2022 20:37
@zmb3 zmb3 requested a review from Joerger March 21, 2022 22:20
Copy link
Contributor

@rosstimothy rosstimothy left a comment

Choose a reason for hiding this comment

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

LGTM

In regards to adding metrics, an interceptor may not necessarily be the best place to do so. Depending on what you are trying to capture a stats.Handler might be a better choice. See the work being done by @NajiObeid for proxy peering as an example: https://github.com/gravitational/teleport/pull/10440/files#diff-8d990324c72abe37d2e979e4f1d582d0de4429065256667df8ef597cc30fef55

@rcanderson23 rcanderson23 enabled auto-merge (squash) March 23, 2022 14:58
@rcanderson23 rcanderson23 merged commit e577b41 into master Mar 24, 2022
@rcanderson23 rcanderson23 deleted the carson/client-dialopts branch March 24, 2022 15:17
rcanderson23 added a commit that referenced this pull request Mar 31, 2022
* change order of dialOpts to respect config provided opts
rcanderson23 added a commit that referenced this pull request Mar 31, 2022
* change order of dialOpts to respect config provided opts
rcanderson23 added a commit that referenced this pull request Apr 4, 2022
* change order of dialOpts to respect config provided opts
rcanderson23 added a commit that referenced this pull request Apr 4, 2022
* change order of dialOpts to respect config provided opts
@webvictim webvictim mentioned this pull request Apr 19, 2022
@webvictim webvictim mentioned this pull request Jun 8, 2022
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.

None yet

4 participants