-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allows Explicitly Enabling/Disabling GAX for Logging/Pubsub #2553
Conversation
def __init__(self, project=None, credentials=None, | ||
http=None, use_gax=True): | ||
super(Client, self).__init__(project, credentials, http) | ||
self.use_gax = use_gax |
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.
Not sure this will cause coverage to go below 100% because the branches are all implicit in one-line Also update the logging |
What does this add that the |
@daspecster It's a manual override, since the gRPC client is b0rken (see the issue that @waprin linked to). |
@daspecster Yes but error reporting currently uses the logging client, it doesn't seem right for one module to be forcing a global environment variable. |
Yeah I looked at the issues. If this gets added, then we may want to set a reminder/issue to take it out once the bug in gRPC is resolved right? |
Currently gax can’t log nested structs, so this is a workaround to allow forced HTTP logging.
f45bfe2
to
c0cd817
Compare
@dhermes added unit test and coverage passes. |
@@ -16,7 +16,6 @@ | |||
|
|||
|
|||
class TestClient(unittest.TestCase): | |||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -66,7 +65,6 @@ def _generated_api(*args, **kw): | |||
return wrapped | |||
|
|||
class _GaxLoggingAPI(object): | |||
|
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.
@@ -475,22 +484,19 @@ def create_scoped(self, scope): | |||
|
|||
|
|||
class _DummyLoggingAPI(object): | |||
|
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
c0cd817
to
d417c1d
Compare
d417c1d
to
fceaacf
Compare
@waprin I think a few things should happen:
|
@dhermes SGTM, will just re-purpose this PR |
3ffc5cd
to
b834d13
Compare
@dhermes added pub/sub. |
b834d13
to
950afd1
Compare
950afd1
to
088e8b4
Compare
@@ -106,7 +106,7 @@ def __init__(self, project=None, | |||
service=None, | |||
version=None): | |||
self.logging_client = google.cloud.logging.client.Client( | |||
project, credentials, http) | |||
project=project, credentials=credentials, http=http, use_gax=False) |
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.
|
||
:type use_gax: bool or :class:`NoneType` | ||
:param use_gax: An optional parameter that explicitly specifies whether | ||
to use the gRPC transport (gax) or HTTP |
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.
|
||
with _Monkey(MUT, _USE_GAX=False): | ||
client = self._makeOne(self.PROJECT, credentials=_Credentials()) | ||
conn = client.connection = object() |
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.
|
||
creds = _Credentials() | ||
with _Monkey(MUT, | ||
_USE_GAX=True): |
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.
def test_no_gax_ctor(self): | ||
from google.cloud.logging.connection import _LoggingAPI | ||
from google.cloud.logging import client as MUT | ||
from google.cloud._testing import _Monkey |
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.
@@ -71,11 +71,23 @@ class Client(JSONClient): | |||
:param http: An optional HTTP object to make requests. If not passed, an | |||
``http`` object is created that is bound to the | |||
``credentials`` for the current object. | |||
|
|||
:type use_gax: bool or :class:`NoneType` |
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.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -71,11 +71,23 @@ class Client(JSONClient): | |||
:param http: An optional HTTP object to make requests. If not passed, an | |||
``http`` object is created that is bound to the | |||
``credentials`` for the current object. | |||
|
|||
:type use_gax: bool or :class:`NoneType` | |||
:param use_gax: An optional parameter that explicitly specifies whether |
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.
|
||
with _Monkey(MUT, _USE_GAX=False): | ||
client = self._makeOne(project=self.PROJECT, credentials=creds) |
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.
|
||
with _Monkey(MUT, _USE_GAX=False): | ||
client = self._makeOne(project=self.PROJECT, credentials=creds) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (merge squash in the UI once Travis is green?)
@dhermes yes please squash merge at your convienence |
Allows Explicitly Enabling/Disabling GAX for Logging/Pubsub
Currently gax can’t log nested structs, so this is a workaround to allow forced HTTP logging.
Workaround to resolve #2521 until #2552 is resolved.