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

feat(spanner): include User agent #3465

Merged
merged 3 commits into from Dec 22, 2020
Merged

Conversation

@mohanli-ml
Copy link
Contributor

@mohanli-ml mohanli-ml commented Dec 15, 2020

Configure the UserAgent in addition to x-goog-api-client. This will be needed for DirectPath.


// clientUserAgent identifies the version of this package.
// It should be the same as https://pkg.go.dev/cloud.google.com/go/spanner.
const clientUserAgent = "spanner-go/v1.12.0"
Copy link
Contributor

@thiagotnunes thiagotnunes Dec 15, 2020

Choose a reason for hiding this comment

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

Could this be dynamic? I am afraid we will forget to update this when a new release comes out.

Loading

Copy link
Contributor

@thiagotnunes thiagotnunes Dec 15, 2020

Choose a reason for hiding this comment

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

For instance, see 4b1db5f.

It would be nice to have a review from @olavloite here too.

Loading

Copy link
Contributor Author

@mohanli-ml mohanli-ml Dec 15, 2020

Choose a reason for hiding this comment

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

It seems we can not do it dynamically in Go. The example you mentioned is in fact define a const, as https://github.com/googleapis/google-cloud-go/blob/master/internal/version/version.go#L29, and https://github.com/grpc/grpc-go/blob/master/version.go#L22.

Loading

Copy link
Collaborator

@olavloite olavloite Dec 16, 2020

Choose a reason for hiding this comment

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

We should really automate this in some way, otherwise it will certainly be forgotten for future releases. The consts that are mentioned above are also automatically generated as part of the release process. The https://github.com/googleapis/google-cloud-go/blob/master/internal/version/version.go#L29 version is generated by this file: https://github.com/googleapis/google-cloud-go/blob/master/internal/version/update_version.sh

Could we for now at least add a TODO here that this needs to be automated with a reference to the bash script mentioned above? This is probably something that we would want to implement for all submodules and integrate in the automated release processes.

Loading

Copy link
Member

@codyoss codyoss Dec 17, 2020

Choose a reason for hiding this comment

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

I agree. Bigtable is the only other client that does this today, and recent PRs have shown that the value has been forgotten about over time. If we were going to start doing something like this I think we should have a consistent header key and value that all of our clients use.

Loading

Copy link
Contributor Author

@mohanli-ml mohanli-ml Dec 17, 2020

Choose a reason for hiding this comment

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

I have added a TODO for automating the user agent. There is a plan to use the library version instead of a date, see #2749, so I guess the best solution is to figure out a way to automatically update the library version for all libraries.

Loading


// clientUserAgent identifies the version of this package.
// It should be the same as https://pkg.go.dev/cloud.google.com/go/spanner.
const clientUserAgent = "spanner-go/v1.12.0"
Copy link
Collaborator

@olavloite olavloite Dec 16, 2020

Choose a reason for hiding this comment

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

We should really automate this in some way, otherwise it will certainly be forgotten for future releases. The consts that are mentioned above are also automatically generated as part of the release process. The https://github.com/googleapis/google-cloud-go/blob/master/internal/version/version.go#L29 version is generated by this file: https://github.com/googleapis/google-cloud-go/blob/master/internal/version/update_version.sh

Could we for now at least add a TODO here that this needs to be automated with a reference to the bash script mentioned above? This is probably something that we would want to implement for all submodules and integrate in the automated release processes.

Loading

@@ -177,6 +177,7 @@ func NewClientWithConfig(ctx context.Context, database string, config ClientConf
),
),
option.WithGRPCConnectionPool(config.NumChannels),
option.WithUserAgent(clientUserAgent),
Copy link
Collaborator

@olavloite olavloite Dec 16, 2020

Choose a reason for hiding this comment

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

I think this will be overridden by any user-agent that a user has specified in the supplied options here:

// opts will take precedence above allOpts, as the values in opts will be
// applied after the values in allOpts.
allOpts = append(allOpts, opts...)

Is that a problem?

Loading

Copy link
Contributor Author

@mohanli-ml mohanli-ml Dec 17, 2020

Choose a reason for hiding this comment

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

This should be good for us. Thanks for catching this!

Loading

@gcf-merge-on-green
Copy link
Contributor

@gcf-merge-on-green gcf-merge-on-green bot commented Dec 22, 2020

Merge-on-green attempted to merge your PR for 6 hours, but it was not mergeable because either one of your required status checks failed, one of your required reviews was not approved, or there is a do not merge label. Learn more about your required status checks here: https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks. You can remove and reapply the label to re-run the bot.

Loading

@thiagotnunes thiagotnunes merged commit 4e1ef1b into googleapis:master Dec 22, 2020
3 checks passed
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants