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

client: Add dial option to disable global dial options #6016

Merged
merged 2 commits into from
Feb 14, 2023

Conversation

zasweq
Copy link
Contributor

@zasweq zasweq commented Feb 11, 2023

This PR adds a dial option to disable global dial options. This will be used in the observability module only, thus it is kept internal. The intended use case is to replace the observability modules instrumentation components registered globally (binary logger, in future: interceptor, and stats handler) to new components (just the interceptor and stats handler) for certain Client Conns (disableGlobalDialOptions + opencensus.DialOption(disableTrace = true). This is to avoid a loop where exporters using grpc.ClientConns create their own telemetry data due to the global registration of instrumentation components.

RELEASE NOTES: N/A

@zasweq zasweq added the Type: Feature New features or improvements in behavior label Feb 11, 2023
@zasweq zasweq added this to the 1.54 Release milestone Feb 11, 2023
@zasweq zasweq requested a review from dfawley February 11, 2023 01:40
Comment on lines 71 to 72
} else {
if !strings.Contains(err.Error(), "no transport security set") {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: combine these lines. You can also combine both cases themselves by doing:

if _, err := Dial("fake", internal.Disable...); !strings.Contains(fmt.Sprint(err), "no transport security set") {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right nice thanks. Switched.


// newDisableGlobalDialOptions returns a DialOption that prevents the ClientConn
// from applying the global DialOptions (set via AddGlobalDialOptions).
func newDisableGlobalDialOptions() DialOption {
Copy link
Member

Choose a reason for hiding this comment

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

Nit/bikeshed: s/new//? Then you'd have to rename disableGlobalDialOptions to disableGlobalDialOptionsOption. Maybe this is fine then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will leave as such.

@dfawley dfawley assigned zasweq and unassigned dfawley Feb 14, 2023
Copy link
Contributor Author

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

Thanks for the pass!


// newDisableGlobalDialOptions returns a DialOption that prevents the ClientConn
// from applying the global DialOptions (set via AddGlobalDialOptions).
func newDisableGlobalDialOptions() DialOption {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will leave as such.

Comment on lines 71 to 72
} else {
if !strings.Contains(err.Error(), "no transport security set") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right nice thanks. Switched.

@zasweq zasweq changed the title client: Added dial option to disable global dial options client: Add dial option to disable global dial options Feb 14, 2023
@zasweq zasweq merged commit 8153410 into grpc:master Feb 14, 2023
1 check passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants