X Tutup
Skip to content

Label more solr queries for monitoring + some SubjectEngine, QueryLabel refactoring#11312

Merged
jimchamp merged 8 commits intointernetarchive:masterfrom
cdrini:refactor/subject-engine
Sep 29, 2025
Merged

Label more solr queries for monitoring + some SubjectEngine, QueryLabel refactoring#11312
jimchamp merged 8 commits intointernetarchive:masterfrom
cdrini:refactor/subject-engine

Conversation

@cdrini
Copy link
Collaborator

@cdrini cdrini commented Sep 25, 2025

We were today hit with high traffic to our subject and author pages, but were unable to see the labelled requests in our solr dashboards. The pages are now labelled with:

  • SUBJECT_ENGINE_PAGE and SUBJECT_ENGINE_API. Note this also includes /publisher pages, which are in essence the same.
  • AUTHOR_BOOKS_PAGE for author pages
  • GET_WORK_SOLR_DATA has been added to label when solr data is fetched via the Work._solr_data() model method. This happens on a lot of pages, but is fast.

UNLABELLED has also been modified to suffix with the type of request made, eg UNABELLED_SELECT, UNLABELLED_GET, etc.

Technical

  • Refactors SubjectEngine to have a simpler class hierarchy by removing the SubjectMeta class. Now there is only one SubjectEngine class that is sub-classed for publishers and languages.
  • Also renames QueryLabel to SolrRequestLabel to allow us in the future to use it to also monitor e.g. solr /update calls.

Testing

✅ ol-solr1 shows the new label after deploying to testing:
image

Screenshot

image

Stakeholders

@cdrini cdrini marked this pull request as ready for review September 25, 2025 17:37
Copilot AI review requested due to automatic review settings September 25, 2025 17:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds monitoring labels to subject page Solr queries and refactors the SubjectEngine class hierarchy. The main goal is to improve observability of subject and publisher page traffic in Solr dashboards by labeling queries with SUBJECT_ENGINE_PAGE and SUBJECT_ENGINE_API.

  • Simplifies SubjectEngine class hierarchy by removing SubjectMeta and making SubjectEngine a dataclass
  • Renames QueryLabel to SolrRequestLabel for broader future use with other Solr operations
  • Adds request_label parameters throughout the codebase to properly label Solr queries

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openlibrary/plugins/worksearch/subjects.py Refactors SubjectEngine to dataclass, removes SubjectMeta, adds request labels
openlibrary/plugins/worksearch/publishers.py Converts PublisherEngine to dataclass with proper inheritance
openlibrary/plugins/worksearch/languages.py Converts LanguageEngine to dataclass with proper inheritance
openlibrary/plugins/worksearch/code.py Renames QueryLabel to SolrRequestLabel and updates parameter names
openlibrary/plugins/openlibrary/partials.py Updates parameter name from query_label to request_label
openlibrary/macros/RawQueryCarousel.html Updates parameter name from query_label to request_label

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

engine = next((e for e in SUBJECTS if key.startswith(e.prefix)), None)

if not engine:
raise NotImplementedError(f"No SubjectEngine for key: {key}")
Copy link

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message uses NotImplementedError which typically indicates missing functionality, but this is actually a case of an invalid/unsupported key. Consider using ValueError with a more descriptive message like 'Unsupported subject key format: {key}'

Suggested change
raise NotImplementedError(f"No SubjectEngine for key: {key}")
raise ValueError(f"Unsupported subject key format: {key}")

Copilot uses AI. Check for mistakes.
@cdrini cdrini added the Patch Deployed This PR has been deployed to production independently, outside of the regular deploy cycle. label Sep 26, 2025
@cdrini
Copy link
Collaborator Author

cdrini commented Sep 26, 2025

Patch deploying to help get some visibility into the current influx of traffic

@cdrini cdrini changed the title Label subject page solr queries for monitoring + some SubjectEngine, QueryLabel refactoring Label more solr queries for monitoring + some SubjectEngine, QueryLabel refactoring Sep 26, 2025
@cdrini cdrini added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Sep 29, 2025
@jimchamp jimchamp merged commit 9c64aa9 into internetarchive:master Sep 29, 2025
4 checks passed
@cdrini cdrini deleted the refactor/subject-engine branch September 29, 2025 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Patch Deployed This PR has been deployed to production independently, outside of the regular deploy cycle. Priority: 1 Do this week, receiving emails, time sensitive, . [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup