-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Backend Logging #160
Comments
hello, i would like to assist in this issue though I'm new to open source stuff but I know the basics of logging |
Hi @aarshgupta24. All yours, let me know if you need anything. |
Hi @aarshgupta24, I made some backend changes during the wekeed. They should impact much on your task but consider keeping your branch up to date 😃 |
got it @AntonioMrtz |
Hi @AntonioMrtz , I have a doubt like there in no logging constant defined for login folder in spotify_electron , so should I initialize one or there is no need for that folder to have a logger? |
Hi @aarshgupta24 , I dont know if I understood correctly but i will try to answer:
By establishing As you see logging constants are not associated with packages/folders but with modules/files/classes.
Keep in mind that log level (debug,info...) matters. We dont want the app on info mode to be full of logs but they should be enough to trace whats happening. In debug mode you can have more logs that shows attributes or other meaninful data. Example:
Im not close on how logging should be done and what content should it have so I think the best will be to make the improvements/changes on one entity of the app such as playlist. Then I can review the changes and we can figure it out what we like/dont like and establish some kind of standard to apply on the rest of the modules. Making a proposal for Playlist entity (repo,schema,controller,service) sounds interesting as its the base/default entity of the project and contains common and specific logic. About your last question, I would try to keep a similar structure, I dont think theres a need to add a ton of new logs but maybe Im wrong. By reviewing the proposed changes on playlist logging we can get closer and closer to what we actually want. Sorry about the size of the answer 🤣 but I think it can be useful. |
thank you @AntonioMrtz , I was a little nervous as this is my time contributing and I was also thinking of asking you to review my work so that I don't mess the the things. |
Hi @AntonioMrtz , I am attaching the proposal in this comment. |
Hi @aarshgupta24, thanks for your time and your proposed ideas.I took a quick look and It looks good. I will check it out more closely and give you feedback in 1-2 days max. 🙂 |
Hi, I analized the proposal and now I can defined more precisely what were searching for and how it should be done. Lets keep this an interative process until we find a definitive solution. Basics
Logging ProposalCommon logging templates
Something like this could be good. Templates should be stored in another module.
Controller
Repository
Service
Validations checks
Schema
More descriptive exceptionsAs shown here its not recommended to throw exceptions with a message. This can lead to the same exception being raised with different messages across the app, losing traceability. I would like to know what raising exceptions with custom messages gives us if were already logging messages associated to the raised exceptions. Im not close on introducing it but Im not really sure it will have an advantage. General guidelines
New tasks (Out of scope for this issue)
Again, thanks for your time. Im open to talk about any question/suggestion but I think we can use this schema for a first approach/iteration of the logging issue were facing. The next phase can be putting everything we have got into a conclussion in this thread in the actual |
hi @AntonioMrtz , thank you for this now i will try to keep all this in my mind, i will first implement the schema part just i one thing that after the logging message should raise exception(without the message) or not ? |
hi @aarshgupta24 . Yeah I think we should. The exception will be catch by the big except Exception on repository and service giving us more info about what happen. I thinks this is a good way because the exception handling will be the same for a 500 error and trying to converto document-dao-dto. In exception blocks make sure to use (ConvertionException,Exception), is redundant but is easier to see whats getting catch. Log convertion errors in exception mode (the debug mode I told you was for sucessful operation but I dont thinks its necessary) and then raise the convertion error. |
Hi @aarshgupta24 , the issue #164 and #165 are related to this task. Maybe you want to tackle them first. This tasks can be made before this issue because theyre a basicly subtask. |
hi @AntonioMrtz , i will go through both of them and let you know and revert back you on 14th as i have a interview scheduled on 13th |
@aarshgupta24 |
Hi @AntonioMrtz , I think i will first handle the issue #164. |
if im correct in issue #164 , the file playlist_repositry_validation.py we have used handle and in playlist_service_validation.py we have used validate, so you want me to change handle to validate and also rather than an if statement replace it with try-except block? |
Hi, I think you have to comment in #164 so I can add you as assignee. Rename all validations to the same name pattern
|
Hi @aarshgupta24 are you still working on this issue? |
hi @AntonioMrtz , i'm really sorry my college opened up and since then i'm really having a very hard time figuring out time for this. |
Hi @aarshgupta24 thanks for all your work in this project. Feel free to come back and contribute anytime you want 😃 |
Hey @AntonioMrtz would you mind if I take a crack at this? Proposals:
I can also start working on the other mentioned issues:
|
Hi @coyster , nice to meet you. Yeah, thanks for taking the issue. Let me know if you need anything while working on this issue :). We also have the project docs that gathers all the info, methodology and common questions. Feel free to check it out if you wanna know about the project and how we colaborate. 🎯 ObjectivesWhat we want to achieve:
Optional(can be done in this issue or not)Implement Frontend: get playlist -> It will be nice to have a custom header for frontend requests that has an uuid for tracing all the steps related to an operation. Backend would take the uuid and use it to log the steps made. If this is too much we can leave it for another issue, I would take part of it for the front side if you're OK with that. ✨ Current SituationI think it's important to know how the app behaves right now so we can tackle the issue more accurately. Let's take trying to get a non existent playlist as an example.
(1) As you can see we have traces about the all functions and modules that takes part on the operation and handles the incoming request. I'm not opposed to the idea of moving into templates either. (2) Having logs into the exceptions was something I thought about when backend refactor occured. It can be a great idea. Code reusability and consistency could be achieved by following your second point, I'm definitely in favour of that. 🔨 How to proceedI think we can test a mix of your ideas and my feedback in a little prototype and iterate over that. We could start by making a code proposal for only getting a playlist that doesn't exists, like in the example above. Once we have a clearly defined line of work we can use this operation for iterating purposes |
@AntonioMrtz Code change / sow is attached See Question for pydantic model for incoming header Let me know what you think, and I'll start working |
Hi @coyster , I wrote a response one day ago but it didnt get sent jajajaja. I will answer you again asap
|
Hi again @coyster, first of all thanks for your time. (3) UUIDI'm using this middleware at my current job https://github.com/snok/asgi-correlation-id. I think it can get the job done and we only will have to modify the format of the logging messages at base SpotifyLogger. Prop drilling request info from the endpoints doesn't sound good at all.Tell me if the middleware sounds good to you. (1) (2) (4) Exception loggingI like the extra args method for giving context to the exception. If we combine that with using pre-defined messages we can achieve readability and reusability
Tell me if you have any questions, I wrote it from memory since so it may not be as exact as the message that didn't get sent :) Maybe we can start the PR by doing this refactor to playlist related and global stuff. This way we can iterate over the code until we're certain about how we exactly want to organize everything |
Hi again @coyster, another requirement for the task will be selecting the correct log level across layers such as repository and service. Having a consistent log level is key, I notice there're some repository methods that log on info on success while other do it on debug. Others directly don't log anything (they should). |
Hi @coyster are you still working in this issue :) ? If you need help with something just let me know 🖐️ |
Description
The following is wanted for improving backend logging:
The main goal for logging in the project was to detect app behaviour and errors without getting even into the code. The logs should be concise, clear and representative enough to achieve that goal. Implement this issue with that main goal in mind, as it was done before on backend refactor branch.
Context
The branch for refactoring backend was long and took several months, this caused logs to be inconsistent and sometimes incorrect.
How to do it
Take a look at backend and search for improvements & errors associated with logging
Testing
The text was updated successfully, but these errors were encountered: