-
Notifications
You must be signed in to change notification settings - Fork 1.6k
DISCUSSION PR: Add __environ__ to gcloud package to augment user agent #573
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
Conversation
Changes Unknown when pulling cf58724 on dhermes:fix-566 into * on GoogleCloudPlatform:master*. |
Changes Unknown when pulling 5324510 on dhermes:fix-566 into * on GoogleCloudPlatform:master*. |
Making an HTTP request at import time is Just Wrong (TM). We should either make an instance of a class with a property which computes |
I like it. Will re-work with this in mind. I'm a little scared of what unit tests will look like. |
a53d2c8
to
1d4c4de
Compare
Temporary commit for PR googleapis#573.
@tseaver I changed to using a lazy loading property with I also debated using a default Why can't GCE be detected without an HTTP request? Bah! I'm a bit hesitant with this current approach since we have a Another thing I wanted to do: set |
Something like Pyramid's |
Maybe we should allow applications to pass in a string to be added to the agent? |
|
@tseaver PTAL. I held off on
Will cover in another PR if you're OK with that. |
Also I had to add a |
@@ -45,6 +39,11 @@ def __init__(self, credentials=None): | |||
self._http = None | |||
self._credentials = credentials | |||
|
|||
@gcloud._UserAgentReifyProperty # pragma: NO COVER |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Deferring the "custom" agent stuff is fine by me. |
Or move the logic down into the |
We want to leave the logic outside of
I'm fine with hard-coding |
I was thinking more of something like this gist. |
|
Using a decorator to wrap a no-op function smells bad to me.
I was addressing #573 (comment). If there were "well known" apps which used the feature, then one might be able to pick their traffic out of the logs.
I had assumed that it would just use the value of |
|
It seemed useful to me to preserve the "library" info along with the application-specific tag.
I hadn't meant to force it at import time; rather, I would use |
|
Using the property on Connection instances instead of setting as a class property / attribute. Fixes googleapis#566.
This prevents unnecessary HTTP requests to determine if GCE is the current environment. Also updating Test__UserAgentReifyProperty with - setUp and tearDown to make sure a fresh _UserAgentReifyProperty is associated with the Connection class in every test case - test___get___access_twice test case added to test the branches in __get__ for pre-cache and post-cache states
Yes: the whole notion requires an instance to hold the cached computed values.
I don't care about the class, per se. I was assuming that the instance might be part of the API, assuming apps might care about using its methods in the same way that the connection does. |
* chore: Update gapic-generator-python to v1.11.2 PiperOrigin-RevId: 546510849 Source-Link: googleapis/googleapis@736073a Source-Link: googleapis/googleapis-gen@deb64e8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGViNjRlOGVjMTlkMTQxZTMxMDg5ZmU5MzJiM2E5OTdhZDU0MWM0ZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
See #566.
This should not be merged (uses lots of
pragma: NO COVER
), it is just a quick and dirty way to go about it.The App Engine import is innocuous, but the Compute Engine metadata server HTTP should not happen every single time
gcloud
is imported (or any sub-package / sub-module). This is the thing I want to discuss.