Skip to content
Open
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9227999
Added a "recent times" that allows us to track query times.
gaurav Dec 18, 2025
ddeb95d
Improved name.
gaurav Dec 18, 2025
aa48597
Merge branch 'master' into track-recent-times
gaurav Dec 18, 2025
e47524e
Merge branch 'master' into track-recent-times
gaurav Apr 7, 2026
e17e784
Cleaned up code.
gaurav Apr 7, 2026
580d6f8
Add Solr native metrics and separate Solr latency tracking to /status
gaurav Apr 7, 2026
a2e998e
Address code review feedback on /status metrics
gaurav Apr 7, 2026
c8e876e
Gate solr_metrics behind ?metrics=true to avoid adding latency to /st…
gaurav Apr 7, 2026
e094153
Update api/server.py
gaurav Apr 7, 2026
2e9bfa9
Cleaned up solr_metrics inclusion.
gaurav Apr 7, 2026
a4a1d1d
Dedup SOLR_CORE_NAME.
gaurav Apr 7, 2026
e8a4a00
Fix typo.
gaurav Apr 7, 2026
17c4107
Attempt to reorganize and fix tests.
gaurav Apr 7, 2026
38677c3
Improved recent_queries output.
gaurav Apr 7, 2026
1361c04
Merge remote-tracking branch 'origin/main' into track-recent-times
gaurav Jul 23, 2026
96405dc
Adapt /status metrics to main: drop hardcoded core name, fix API docs
gaurav Jul 23, 2026
975a8a1
Enrich /status?metrics=true with host + GC metrics for pod sizing
gaurav Jul 23, 2026
40434bc
Grow recent-times window to 50000, add api_node_memory, gate on ?full…
gaurav Jul 23, 2026
0fa48da
Drop api_node_memory from /status
gaurav Jul 23, 2026
140d5cc
Pick up slow-query logging and filterCache from PR #253
gaurav Jul 23, 2026
c26b9c2
Add Performance.md diagnostics guide (adapted from PR #253)
gaurav Jul 23, 2026
74d4ef2
Add end-to-end latency percentiles; trim misleading/low-value metrics
gaurav Jul 24, 2026
c9764bb
Document where Solr's GC log actually goes
gaurav Jul 24, 2026
4581917
Test the slow-query logging threshold
gaurav Jul 24, 2026
c3a4a6d
Record the Solr metrics encoding trap; refresh /status docs
gaurav Jul 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
import os
import re
from collections import deque
from enum import Enum
from typing import Dict, List, Union, Annotated, Optional

Expand All @@ -35,6 +36,10 @@
allow_headers=["*"],
)

# We track the time taken for each Solr query for the last 1000 queries so we can track performance via /status.
RECENT_TIMES_COUNT = os.getenv("RECENT_TIMES_COUNT", 1000)
Comment thread
gaurav marked this conversation as resolved.
Outdated
recent_query_times = deque(maxlen=RECENT_TIMES_COUNT)

# ENDPOINT /
# If someone tries accessing /, we should redirect them to the Swagger interface.
@app.get("/", include_in_schema=False)
Expand Down Expand Up @@ -110,6 +115,11 @@ async def status() -> Dict:
'segmentCount': index.get('segmentCount', ''),
'lastModified': index.get('lastModified', ''),
'size': index.get('size', ''),
'recent_queries': {
'count': len(recent_query_times),
'mean_time_ms': sum(recent_query_times) / len(recent_query_times) if recent_query_times else -1,
'recent_times_ms': list(recent_query_times),
}
Comment thread
gaurav marked this conversation as resolved.
Outdated
}
else:
return {
Expand Down Expand Up @@ -605,9 +615,12 @@ async def lookup(string: str,
debug=debug_for_this_request))

time_end = time.time_ns()
time_taken_ms = (time_end - time_start)/1_000_000
time_taken_ms_solr = (time_solr_end - time_solr_start)/1_000_000
recent_query_times.append(time_taken_ms)

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The comment and variable name suggest you're tracking “Solr query time”, but the value appended is time_taken_ms (overall request time including non-Solr processing). This makes /status's recent_queries.mean_time_ms ambiguous/misleading. Either append time_taken_ms_solr (if you want Solr time) or rename the variables/keys to reflect total request timing (or expose both metrics separately).

Suggested change
recent_query_times.append(time_taken_ms)
recent_query_times.append(time_taken_ms_solr)

Copilot uses AI. Check for mistakes.
logger.info(f"Lookup query to Solr for {json.dumps(string)} " +
f"(autocomplete={autocomplete}, highlighting={highlighting}, offset={offset}, limit={limit}, biolink_types={biolink_types}, only_prefixes={only_prefixes}, exclude_prefixes={exclude_prefixes}, only_taxa={only_taxa}): "
f"took {(time_end - time_start)/1_000_000:.2f}ms (with {(time_solr_end - time_solr_start)/1_000_000:.2f}ms waiting for Solr)"
f"took {time_taken_ms:.2f}ms (with {time_taken_ms_solr:.2f}ms waiting for Solr)"
)

return outputs
Expand Down
Loading