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

Add Async Background Thread transport #1942

Merged
merged 1 commit into from
Jul 28, 2016

Conversation

waprin
Copy link
Contributor

@waprin waprin commented Jun 29, 2016

Next step: asynchronous transport using a background thread.

Some notes:

  1. This includes a bugfix where Batch entries were writing logNames incorrectly
  2. Background thread just writes to an entry and keeps re-using it. Seemed ok?
  3. I didn't add a base Transport class yet, though possibly I should? With just a send message that raises NotImpementedException
  4. Background thread will pretty much write an entry as soon as it shows up, although it's possible for a few entries to be written before it's scheduled. I want to run some performance tests on all these handlers and at that point I will start seeing if it would make a difference to wait for more entries to be written before committing them
  5. Docs are getting kind of messy, feel like I might need more nesting. If other people agree I can try to spend more time on it
  6. We should be using Stackdriver Logging everywhere, not CloudLogging. Will fix that all in one go in future PR.

Next handler up will be fluentd.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 29, 2016
@waprin
Copy link
Contributor Author

waprin commented Jun 29, 2016

/cc @sharbison3 @filipjs @jonparrott

@waprin
Copy link
Contributor Author

waprin commented Jun 29, 2016

Actually I think I should add the Base transport class, will add that quickly first...

@waprin waprin force-pushed the master branch 4 times, most recently from d0e8da2 to f5b9da5 Compare June 30, 2016 20:40
@waprin
Copy link
Contributor Author

waprin commented Jun 30, 2016

Added base Transport class, Travis passes, review/merge at your convenience.

entries on a background :class:`python.threading.Thread`.

1. :class:`gcloud.logging.handlers.SyncTransport` this handler does a direct API call on each
logging statement to writ the entry.

This comment was marked as spam.

@waprin waprin force-pushed the master branch 2 times, most recently from d6b9658 to 9e30584 Compare July 6, 2016 22:15
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jul 6, 2016
@waprin
Copy link
Contributor Author

waprin commented Jul 7, 2016

@tseaver was waiting for review/merge, I just rebased it onto origin/master but now it thinks all those commits are mine. Not sure how to fix?

@tseaver
Copy link
Contributor

tseaver commented Jul 8, 2016

@waprin is 9e30584 the only "real" commit for this PR? I think you should've rebased it against the logging-stdlib-handler-feature branch, rather than master.

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jul 8, 2016
@waprin waprin force-pushed the master branch 2 times, most recently from a6bc526 to 61c88a6 Compare July 8, 2016 19:58
@waprin
Copy link
Contributor Author

waprin commented Jul 8, 2016

@tseaver ok i rebased it, i was trying to merge upstream but I think I did that wrong and I'll just hold off on it for now.

Travis is now failing the lint but looks like origin/master is too so I'm guessing it's not related to this PR.

@daspecster
Copy link
Contributor

daspecster commented Jul 14, 2016

@waprin, we've been battling with pylint and a few things. I think if you rebase again, it will fix this lint error in travis.

image

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jul 14, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 15, 2016
@daspecster
Copy link
Contributor

@waprin Yay!

@waprin
Copy link
Contributor Author

waprin commented Jul 15, 2016

@daspecster yes thanks for help. System tests are failing so will fix that then ping for review

@waprin waprin force-pushed the master branch 3 times, most recently from 0576f1d to a62781c Compare July 15, 2016 21:46
http)
logger = self.client.logger(name)
self.worker = _Worker(logger)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@waprin
Copy link
Contributor Author

waprin commented Jul 15, 2016

@daspecster ready for another review at your convenience, just mentioned yo in another comment about the need for the class to copy the client.

while not self.stopping:
if len(self.batch.entries) == 0:
# branch coverage of this code extremely flaky
self._entries_condition.wait() # pragma: NO COVER

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@waprin
Copy link
Contributor Author

waprin commented Jul 25, 2016

So where are we leaving off with this?

@daspecster
Copy link
Contributor

@tseaver @dhermes WDYT?

@dhermes
Copy link
Contributor

dhermes commented Jul 26, 2016

I'm too out of the loop to comment

@waprin
Copy link
Contributor Author

waprin commented Jul 27, 2016

@tseaver ping

@waprin
Copy link
Contributor Author

waprin commented Jul 28, 2016

@tseaver @dhermes @daspecster Been almost a month, would like this to get merged and the feature branch to get merged into master, what's going on?

@jgeewax
Copy link
Contributor

jgeewax commented Jul 28, 2016

@daspecster : Can you take a look?

@daspecster
Copy link
Contributor

@jgeewax sure, I have already a little bit and @waprin addressed my questions. So, LGTM at the moment!

@daspecster
Copy link
Contributor

I'll merge if we're good to go?

Refactors handlers into separate package

Adds background threaded transport

Adds fix to Batch commit to properly set log
name
@waprin
Copy link
Contributor Author

waprin commented Jul 28, 2016

Had to kill shebang (since realized it's a bad thing to have in default template), but after Travis passes we can merge.

This is still just into a feature branch so we can still have Tres take a final pass before merge into master.

@waprin
Copy link
Contributor Author

waprin commented Jul 28, 2016


Traceback (most recent call last):
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/.tox/py26/lib/python2.6/site-packages/nose/loader.py", line 418, in loadTestsFromName
addr.filename, addr.module)
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/.tox/py26/lib/python2.6/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/.tox/py26/lib/python2.6/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/gcloud/logging/init.py", line 17, in
from gcloud.logging.client import Client
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/gcloud/logging/client.py", line 42, in
from gcloud.logging.entries import ProtobufEntry
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/gcloud/logging/entries.py", line 20, in
from google.protobuf.json_format import Parse
File "/home/travis/build/GoogleCloudPlatform/gcloud-python/.tox/py26/lib/python2.6/site-packages/google/protobuf/json_format.py", line 48, in
from ordereddict import OrderedDict #PY26
ImportError: No module named ordereddict

😢

@tseaver
Copy link
Contributor

tseaver commented Jul 28, 2016

Ugh. That dependency is restored on master. Let me look at fixing the target branch.

@tseaver
Copy link
Contributor

tseaver commented Jul 28, 2016

I merged master to the logging-stdlib-handler-feature branch, and restarted Travis. Fingers crossed.

@tseaver
Copy link
Contributor

tseaver commented Jul 28, 2016

... and the bulid is green. Whew!

@@ -0,0 +1,7 @@
Python Logging Handler Sync Transport
======================================

This comment was marked as spam.

@tseaver tseaver merged commit 930342a into googleapis:logging-stdlib-handler-feature Jul 28, 2016
@waprin
Copy link
Contributor Author

waprin commented Jul 28, 2016

Thanks, will fix those issues in final commit before I aim for a master merge (fluentd handler).

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.

7 participants