Skip to content

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 waprin force-pushed the logging_gax_optional branch from f45bfe2 to c0cd817 Compare October 17, 2016 21:43
@waprin
Copy link
Contributor Author

waprin commented Oct 17, 2016

@dhermes added unit test and coverage passes.



class TestClient(unittest.TestCase):

This comment was marked as spam.

return wrapped

class _GaxLoggingAPI(object):

This comment was marked as spam.

This comment was marked as spam.



class _DummyLoggingAPI(object):

This comment was marked as spam.

@waprin waprin force-pushed the logging_gax_optional branch from c0cd817 to d417c1d Compare October 17, 2016 23:59
@waprin waprin force-pushed the logging_gax_optional branch from d417c1d to fceaacf Compare October 18, 2016 00:00
@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 force-pushed the logging_gax_optional branch from 3ffc5cd to b834d13 Compare October 20, 2016 21:24
@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.

@waprin waprin force-pushed the logging_gax_optional branch from b834d13 to 950afd1 Compare October 20, 2016 22:30
@waprin waprin force-pushed the logging_gax_optional branch from 950afd1 to 088e8b4 Compare October 20, 2016 22:31
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.

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

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

conn = client.connection = object()

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.

conn = client.connection = object()

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
parthea pushed a commit that referenced this pull request Nov 24, 2025
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