GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Converting Logging client->list_entries to iterator. by dhermes · Pull Request #2636 · googleapis/google-cloud-python

Conversation

@dhermes

@dhermes dhermes commented Oct 28, 2016 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@waprin @jonparrott I just realized how weird the logging HTTP/JSON API is. For /entries:list, POST is used instead of GET, and the "query params" come in the payload instead of as query params.

Just as #2633 started, I'm sending this out without fixing unit tests to get it in the hands of reviewers. The unit tests may take me a non-trivial time, but I am working on them.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dhermes
Converting Logging client->list_entries to iterator.
08fda01
@dhermes dhermes added api: core api: logging Issues related to the Cloud Logging API. labels Oct 28, 2016
@dhermes dhermes assigned daspecster and tseaver Oct 28, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 28, 2016
@dhermes
Adding unit tests for HTTPIterator GET/POST switching.
bc0c3c4
@theacodes

theacodes commented Oct 28, 2016

Copy link
Copy Markdown
Contributor

iirc logging has some very strange behavior with listing entries, I think @waprin is pretty familiar with it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@waprin

waprin commented Oct 28, 2016

Copy link
Copy Markdown
Contributor

Yes specifically it uses the page tokens as a progress indicator, not just as a means of breaking results into pages. This means you can get 0 results on first page, but then 10 results on the next page, so you really always want to check the page token. This is especially true for slower queries, which are most of them without an index e.g. logName= .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes
Adding unit tests for Logging list_entries() change.
e38908e
@dhermes

dhermes commented Oct 28, 2016

Copy link
Copy Markdown
Contributor Author

@tseaver @daspecster PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Oct 28, 2016

Copy link
Copy Markdown
Contributor Author

@waprin So what are the implications for using an Iterator? It'll just take a long time consuming empty pages until the results are available?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@waprin

waprin commented Oct 28, 2016

Copy link
Copy Markdown
Contributor

@dhermes yeah, if anything I'm thinking this is a very good change because with the iterator people are less likely to get no results on the first page and think there are no results.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@theacodes

theacodes commented Oct 28, 2016

Copy link
Copy Markdown
Contributor

@waprin is there a possibility the iterator will never finish?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daspecster
daspecster reviewed Oct 29, 2016
View reviewed changes
Comment thread core/google/cloud/iterator.py
method='GET', path=self.path,
query_params=self._get_query_params())
params = self._get_query_params()
if self._HTTP_METHOD == 'GET':

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread core/unit_tests/test_iterator.py
'data': {},
})

def test__get_next_page_bad_http_method(self):

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/logging-usage.rst
>>> client = logging.Client()
>>> entries, token = client.list_entries() # API call
>>> for entry in entries:
>>> for entry in client.list_entries(): # API call(s)

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread logging/google/cloud/logging/_helpers.py
"""Detect correct entry type from resource and instantiate.

:type resource: dict
:param resource: one entry resource from API response

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread logging/google/cloud/logging/_helpers.py
elif 'protoPayload' in resource:
return ProtobufEntry.from_api_repr(resource, client, loggers)

raise ValueError('Cannot parse log entry resource')

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread logging/unit_tests/test__gax.py
entry_pb = LogEntry(log_name=self.LOG_NAME,
timestamp = datetime.datetime.utcnow().replace(tzinfo=UTC)
timestamp_pb = _datetime_to_pb_timestamp(timestamp)
entry_pb = LogEntry(log_name=self.LOG_PATH,

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver
tseaver reviewed Oct 31, 2016
View reviewed changes
Comment thread core/google/cloud/iterator.py
return self.client.connection.api_request(
method=self._HTTP_METHOD,
path=self.path,
data=params)

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes dhermes mentioned this pull request Oct 31, 2016
AppVeyor build currently failed due to timestamp format zero padding #2650
Closed
@waprin

waprin commented Oct 31, 2016

Copy link
Copy Markdown
Contributor

@jonparrott can't think of a way

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

@tseaver LGTY to merge?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

theacodes
theacodes approved these changes Oct 31, 2016
View reviewed changes
@dhermes
dhermes merged commit 016415a into googleapis:master Oct 31, 2016
@dhermes
dhermes deleted the logging-iterators-1 branch October 31, 2016 17:15
@dhermes

dhermes commented Oct 31, 2016

Copy link
Copy Markdown
Contributor Author

As discussed with @daspecster, going to make the docstring updates in a follow-up PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Oct 31, 2016
@dhermes
Docstring update follow-up from PR googleapis#2636.
9a3e3b2
dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Oct 31, 2016
@dhermes
Docstring update follow-up from PR googleapis#2636.
d23c1f8
dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Oct 31, 2016
@dhermes
Docstring update follow-up from PR googleapis#2636.
45bf564
@dhermes dhermes mentioned this pull request Nov 14, 2016
Upgrading core to version to 0.21.0. #2733
Merged
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
@dhermes
Merge pull request googleapis#2636 from dhermes/logging-iterators-1
b5902a0
Converting Logging client->list_entries to iterator.
richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
@dhermes
Docstring update follow-up from PR googleapis#2636.
c149782
@theacodes theacodes unassigned daspecster Sep 28, 2018
parthea pushed a commit that referenced this pull request Nov 24, 2025
@dhermes
Merge pull request #2636 from dhermes/logging-iterators-1
2f63c3c
Converting Logging client->list_entries to iterator.
parthea pushed a commit that referenced this pull request Nov 24, 2025
@dhermes
Docstring update follow-up from PR #2636.
be69248
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

3 more reviewers
@daspecster daspecster daspecster left review comments
@tseaver tseaver tseaver left review comments
@theacodes theacodes theacodes approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@tseaver tseaver

Labels

api: core api: logging Issues related to the Cloud Logging API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@dhermes @theacodes @waprin @daspecster @tseaver @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.