Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add more logging to ES query builder #776

Closed
wants to merge 2 commits into from

Conversation

sarayourfriend
Copy link
Contributor

Fixes

Fixes WordPress/openverse#689 by @sarayourfriend

Description

Adds request IDs to all logs so that we can trace them easily throughout a request without having to rebuild it ourselves (we can simply query for the request ID and then follow a request's logs in their entirety).

Also begins the process of adding logs to the search_controller around the pagination logic. I'm stumped by this branch though and am unsure how to describe it in the logs:

else:
accu_query_mask = list(accumulate(query_mask))
start = 0
if page > 1:
try:
start = accu_query_mask.index(page_size * (page - 1) + 1)
except ValueError:
start = accu_query_mask.index(page_size * (page - 1)) + 1
if page_size * page > sum(query_mask):
end = ceil(page_size * page / (1 - DEAD_LINK_RATIO))
else:
end = accu_query_mask.index(page_size * page) + 1

@dhruvkb @krysal @obulat do any of y'all have any ideas for this? Part of the problem is I'm unclear on how the link mask works and in particular this call is confusing the heck out of me:

accu_query_mask = list(accumulate(query_mask))

I have no idea what it's meant to do! calling list(accumulate(integer_list)) basically builds out a factorial-ish kind of list as a result...

>>> list(accumulate([1, 2, 3, 4, 5]))
[1, 3, 6, 10, 15]

I have absolutely zero clue about what this is meant to be doing for us here. If anyone can help explain this then I will also add some comments to this bit of code (and probably write a doc page about the query masking in general). It's quite cryptic without any context aside from the code!

Testing Instructions

TBD

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@sarayourfriend sarayourfriend changed the title Add/more es builder logic Add more logging to ES query builder Jun 29, 2022
@openverse-bot openverse-bot added 💻 aspect: code Concerns the software code in the repository 🟧 priority: high Stalls work on the project or its dependents 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Jun 29, 2022
@github-actions
Copy link

github-actions bot commented Jun 29, 2022

API Developer Docs Preview: Ready

https://wordpress.github.io/openverse-api/_preview/776

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

@sarayourfriend sarayourfriend added the ⛔ status: blocked Blocked & therefore, not ready for work label Jun 29, 2022
@sarayourfriend
Copy link
Contributor Author

Blocked by the search controller refactor revert being reverted, pending @dhruvkb opening that revert.

@sarayourfriend sarayourfriend mentioned this pull request Jun 29, 2022
6 tasks
@dhruvkb dhruvkb removed the ⛔ status: blocked Blocked & therefore, not ready for work label Jul 5, 2022
@sarayourfriend
Copy link
Contributor Author

Closing in favor of #790

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟧 priority: high Stalls work on the project or its dependents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add additional logging around search_controller's ES query building
3 participants