feat: Added request logging middleware to the backend#489
Open
yughpatel wants to merge 3 commits into
Open
Conversation
…licts in requirements.txt
Owner
|
resolve conflicts |
Author
Will work on it |
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.
📋 PR Checklist
🔗 Related Issue
Closes #36
📝 What does this PR do?
This PR implements custom structured JSON logging using
logurufor the backend, replacing generic console logging with meaningful, context-rich logging tailored to RAG workflows:StructuredLoggingMiddlewareto capture core HTTP metrics (method, path, status code, response time in ms), unique request IDs (X-Request-ID), and authenticated user IDs.filenameandfile_sizeon document uploads (/uploadand/urlupload).querytext andchunks_retrievedcount from the vector database on RAG chat queries and streams (/chat/askand/chat/ask/stream).10 MB), retention (10 days), and compression (zip) written to./data/logs/app.log, loading environment-based log levels (LOG_LEVEL=DEBUGin development,INFOin production).CONTRIBUTING.mdwith guidelines on branch rules, development setup, and hook rules.🗂️ Type of Change
🧪 How was this tested?
uvicorn app.main:app --reload)Details:
backend/data/logs/app.log.📸 Screenshots (if UI change)
N/A
loguruas a new backend dependency inrequirements.txt.request.stateto ensure robust parameter propagation back to the middleware logs across different asyncio task environments.✅ Self-Review Checklist
dev, notmainmainbranch or any HuggingFace deployment config