Summary
Eleven API routers do not set route_class=LoggedRoute on their APIRouter instance. This means requests to those endpoints never emit a canonical api_request log line, creating silent observability gaps that make debugging, alerting, and auditing unreliable.
Problem
LoggedRoute (in src/mavedb/lib/logging/logged_route.py) does two things for every request:
- Stamps
time_ns into the logging context at the start of the request.
- Schedules a
BackgroundTask that calls log_request, which emits a structured canonical log line carrying log_type, response_code, duration_ns, X-Correlation-ID, and other context fields.
Routers that omit route_class=LoggedRoute produce no canonical log output. The following routers are currently missing it:
| Router file |
Tag / prefix |
routers/api_information.py |
GET /api/version |
routers/controlled_keywords.py |
/controlled-keywords |
routers/doi_identifiers.py |
/doi-identifiers |
routers/hgvs.py |
/hgvs (transcript fetch, HGVS validation) |
routers/licenses.py |
/licenses |
routers/publication_identifiers.py |
/publication-identifiers |
routers/raw_read_identifiers.py |
/raw-read-identifiers |
routers/statistics.py |
/statistics |
routers/target_gene_identifiers.py |
/target-gene-identifiers |
routers/target_genes.py |
/me/target-genes/search and /target-genes/search |
routers/taxonomies.py |
/taxonomies |
Of particular note: target_genes.py contains an authenticated endpoint (/me/target-genes/search) where request logging is especially valuable for audit trails.
Proposed Behavior
Every APIRouter in src/mavedb/routers/ should declare route_class=LoggedRoute, so all endpoints emit consistent canonical log lines with timing, correlation IDs, and response codes.
Acceptance Criteria
- All
APIRouter instances in src/mavedb/routers/ include route_class=LoggedRoute.
LoggedRoute is imported from mavedb.lib.logging in each affected file.
- Requests to every endpoint produce a canonical
api_request log line containing at minimum log_type, response_code, duration_ns, and X-Correlation-ID.
- No existing tests are broken by the change.
Implementation Notes
- The fix is mechanical: add
from mavedb.lib.logging import LoggedRoute and route_class=LoggedRoute to the APIRouter(...) call in each of the eleven files listed above.
- The pattern used by every other router is consistent; use
src/mavedb/routers/experiments.py as the reference implementation.
- No behavior changes to existing endpoints are expected —
LoggedRoute only adds a post-response background task.
- Consider adding a test or a linting check (e.g., scanning all
APIRouter instantiations in src/mavedb/routers/) to prevent the gap from reappearing.
Summary
Eleven API routers do not set
route_class=LoggedRouteon theirAPIRouterinstance. This means requests to those endpoints never emit a canonicalapi_requestlog line, creating silent observability gaps that make debugging, alerting, and auditing unreliable.Problem
LoggedRoute(insrc/mavedb/lib/logging/logged_route.py) does two things for every request:time_nsinto the logging context at the start of the request.BackgroundTaskthat callslog_request, which emits a structured canonical log line carryinglog_type,response_code,duration_ns,X-Correlation-ID, and other context fields.Routers that omit
route_class=LoggedRouteproduce no canonical log output. The following routers are currently missing it:routers/api_information.pyGET /api/versionrouters/controlled_keywords.py/controlled-keywordsrouters/doi_identifiers.py/doi-identifiersrouters/hgvs.py/hgvs(transcript fetch, HGVS validation)routers/licenses.py/licensesrouters/publication_identifiers.py/publication-identifiersrouters/raw_read_identifiers.py/raw-read-identifiersrouters/statistics.py/statisticsrouters/target_gene_identifiers.py/target-gene-identifiersrouters/target_genes.py/me/target-genes/searchand/target-genes/searchrouters/taxonomies.py/taxonomiesOf particular note:
target_genes.pycontains an authenticated endpoint (/me/target-genes/search) where request logging is especially valuable for audit trails.Proposed Behavior
Every
APIRouterinsrc/mavedb/routers/should declareroute_class=LoggedRoute, so all endpoints emit consistent canonical log lines with timing, correlation IDs, and response codes.Acceptance Criteria
APIRouterinstances insrc/mavedb/routers/includeroute_class=LoggedRoute.LoggedRouteis imported frommavedb.lib.loggingin each affected file.api_requestlog line containing at minimumlog_type,response_code,duration_ns, andX-Correlation-ID.Implementation Notes
from mavedb.lib.logging import LoggedRouteandroute_class=LoggedRouteto theAPIRouter(...)call in each of the eleven files listed above.src/mavedb/routers/experiments.pyas the reference implementation.LoggedRouteonly adds a post-response background task.APIRouterinstantiations insrc/mavedb/routers/) to prevent the gap from reappearing.