Repository navigation
feat(index): debug-log query type, latency and result count in query() - #750
Merged
Merged
Conversation
Emit one DEBUG record from SearchIndex.query() and AsyncSearchIndex.query() with the index name, query class, elapsed milliseconds and result count. Only the query class name is logged, never the query string or params, and the record is only built when DEBUG is enabled. CountQuery results (an int) are logged as the count. Fixes redis#494 Signed-off-by: Tianlang (Jackie) Chen <305351710+jackiectl2@users.noreply.github.com>
vishal-bala
self-requested a review
October 13, 2026 14:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #494
What
SearchIndex.query()andAsyncSearchIndex.query()now emit a single DEBUG record on theredisvl.index.indexlogger after each query:query()(BaseQuery subclasses, AggregationQuery, HybridQuery, SQLQuery). ForCountQuery, the logged count is the returned total.time.perf_counter()call. Query results and behavior are unchanged.Out of scope / possible follow-up: the optional slow-query warning threshold from the issue (left out to avoid adding new configuration surface without agreement on where it should live), and instrumenting
paginate/batch_query.Testing
tests/unit/test_query_timing_log.py(sync, async, CountQuery, and no record above DEBUG); no Redis needed.make format,make check-sort-imports,make check-types, codespell: clean.make testlocally against redis:8.4: same results as main plus the 4 new passing tests. Tests that download the default HuggingFace vectorizer fail with a proxy error on both main and this branch (environment).--log-level=DEBUGto exercise the new log path against real Redis.Suggested label:
auto:minorNote
Low Risk
Observability-only change on the query path; no API or result semantics changes, with minimal overhead when DEBUG is off.
Overview
SearchIndex.query()andAsyncSearchIndex.query()now record wall time withtime.perf_counter()and, when DEBUG is enabled on theredisvl.index.indexlogger, emit one line per call: index name, query class name only (e.g.VectorQuery,CountQuery), elapsed milliseconds, and result count.Logging is centralized in
_log_query_timingon the shared index base class.CountQueryuses the returned integer as the count instead oflen(). Query strings, filters, and vectors are never written to the log. Above DEBUG, behavior and return values are unchanged aside from the timing call.Unit tests in
test_query_timing_log.pycover sync/async vector queries, count queries, and the absence of records at INFO, using a stubbedsearchso Redis is not required.Reviewed by Cursor Bugbot for commit babcf5c. Bugbot is set up for automated code reviews on this repo. Configure here.