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

Allows Explicitly Enabling/Disabling GAX for Logging/Pubsub #2553

Merged
merged 6 commits into from
Oct 21, 2016

Conversation

waprin
Copy link
Contributor

@waprin waprin commented Oct 17, 2016

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.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 17, 2016
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.

@dhermes
Copy link
Contributor

dhermes commented Oct 17, 2016

Not sure this will cause coverage to go below 100% because the branches are all implicit in one-line or statements. But I can see the branches. So pretty please write some unit tests?

Also update the logging Client docstring with the new argument (pretty sure Pylint will get mad about that).

@daspecster
Copy link
Contributor

What does this add that the DISABLE_GRPC envar doesn't do? Could the workaround just be setting that to True?

@dhermes
Copy link
Contributor

dhermes commented Oct 17, 2016

@daspecster It's a manual override, since the gRPC client is b0rken (see the issue that @waprin linked to).

@waprin
Copy link
Contributor Author

waprin commented Oct 17, 2016

@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.

@daspecster
Copy link
Contributor

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.
@waprin
Copy link
Contributor Author

waprin commented Oct 17, 2016

@dhermes added unit test and coverage passes.

@@ -16,7 +16,6 @@


class TestClient(unittest.TestCase):

This comment was marked as spam.

@@ -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.

@@ -475,22 +484,19 @@ def create_scoped(self, scope):


class _DummyLoggingAPI(object):

This comment was marked as spam.

@daspecster
Copy link
Contributor

@waprin looks like we have a fix to support that structure.

@dhermes
Copy link
Contributor

dhermes commented Oct 19, 2016

@waprin I think a few things should happen:

  1. Close this PR
  2. We can have a new PR which allows use_gax as a constructor argument in all GAX / GAPIC / gRPC supported APIs (or re-purpose this PR to do the same)
  3. We fix error reporting / logging by fixing our b0rken code

@waprin
Copy link
Contributor Author

waprin commented Oct 19, 2016

@dhermes SGTM, will just re-purpose this PR

@waprin waprin changed the title Enable forced HTTP for Error Reporting Add JSONOrGaxClient That Allows Explicitly Enabling/Disabling GAX Oct 20, 2016
@waprin waprin changed the title Add JSONOrGaxClient That Allows Explicitly Enabling/Disabling GAX Allows Explicitly Enabling/Disabling GAX for Logging/Pubsub Oct 20, 2016
@waprin
Copy link
Contributor Author

waprin commented Oct 20, 2016

@dhermes added pub/sub.

@@ -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.


: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.


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.


creds = _Credentials()
with _Monkey(MUT,
_USE_GAX=True):

This comment was marked as spam.

This comment was marked as spam.

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.

@@ -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.

This comment was marked as spam.

@@ -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.


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.


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.

Copy link
Contributor

@dhermes dhermes left a 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?)

@waprin
Copy link
Contributor Author

waprin commented Oct 21, 2016

@dhermes yes please squash merge at your convienence

@dhermes dhermes merged commit 1fab756 into googleapis:master Oct 21, 2016
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Allows Explicitly Enabling/Disabling GAX for Logging/Pubsub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stackdriver ErrorReporter Unexpected Type
4 participants