[19.0] endpoint_log: log endpoint calls in database with api_log

Aperta
#190 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api, backend

Direzione di ricerca

Start with the open question of which repository should host the module, since that decides the dependency direction. Then read fastapi_log in OCA/rest-framework as the model for the bridge, and look at how ir.http._dispatch receives the functools.partial registered by endpoint_route_handler in web-api. Done means a maintainer has chosen the location and a bridge module logs endpoint calls to api.log, with the migration tracked in OCA/rest-framework#616.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Endpoints currently leave no database record of the calls they receive. The log() helper available to code snippets writes manual messages to ir.logging, and nothing records the request and response themselves.

OCA/rest-framework already provides a generic model for this. api_log stores the URL, method, sanitised headers, body, status, timing and stack trace in api.log, and its api.log_collection.mixin adds a log switch and a Logs button to any model. fastapi_log is the bridge for fastapi.endpoint. The 19.0 migration is OCA/rest-framework#616.

I'd like to contribute an endpoint_log bridge for endpoint.endpoint, and I have a working version for 19.0:

  • endpoint.endpoint inherits api.log_collection.mixin.
  • Logging hooks into ir.http._dispatch, which receives the functools.partial that endpoint_route_handler registers for each route. The endpoint record is resolved from it. The controller is not overridden, because routes call it by its dotted path.
  • Logs are written through a separate cursor, as in fastapi_log, so the logs of failed calls are kept.
  • api_log depends only on web, so the dependency stays light.

Question for maintainers: where should this module live?

  1. In web-api, depending on OCA/rest-framework for api_log.
  2. In rest-framework, next to fastapi_log, depending on web-api for endpoint.

I'd lean towards web-api, since the module is about endpoints, but I'm happy to go either way.

@qrtl QT7417

Assisted-by: Claude Opus 5.5

Lingua principale
Python
Stelle
49
Fork
124
Merge medio
4g 13h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OCA/web-api

Tutte le issue di OCA/web-api

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.