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
Better logging for backend components #3939
Conversation
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
b7aed50
to
fd09c66
Compare
…tter-logging Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@namkyu1999 - Few changes:
- logs should be in small cases
- Log field should be in camel cases eg, logrus.Withfield({workflowId: "123"})
- Please use
logrus.SetReportCaller(true)
- this will report the line number in the log where the error occurred.
|
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Can you assign me, please? @imrajdas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the same changes in other areas also.
litmus-portal/graphql-server/pkg/analytics/ops/prometheus/health-check.go
Outdated
Show resolved
Hide resolved
litmus-portal/graphql-server/pkg/analytics/ops/prometheus/health-check.go
Outdated
Show resolved
Hide resolved
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
@@ -149,7 +149,7 @@ func (r *subscriptionResolver) ClusterConnect(ctx context.Context, clusterInfo m | |||
|
|||
err = dbOperationsCluster.UpdateCluster(query, update) | |||
if err != nil { | |||
logrus.Print("Error", err) | |||
log.Error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Error(err) | |
log.Fatal(err) |
@@ -22,7 +22,7 @@ func (r *mutationResolver) CreateImageRegistry(ctx context.Context, projectID st | |||
|
|||
ciResponse, err := imageRegistryOps.CreateImageRegistry(ctx, projectID, imageRegistryInfo) | |||
if err != nil { | |||
logrus.Error(err) | |||
log.Error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you convert all
if err != nil
condition logs to log.Fatal
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @S-ayanide,
log.Fatal
called os.Exit(1)
so that process will exit with status set to 1. Is it okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is the expectation, if something in the middle goes wrong we'd want to terminate that function with a Fatal message.
@amityt correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No log.Fatal
is not required here. It will impact the complete server. Rather a return statement can be added here in this error block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use log.Fatal()
to exit the process, k8s Deployment obj restarts the pod automatically. IMO, It's an unnecessary task. Moreover, all of the logs are deleted so we cannot analyze what is the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, log.Fatal()
should not be used here. 👍🏼
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, requested some minor changes.
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Signed-off-by: namkyu1999 <lak9348@konkuk.ac.kr>
Proposed changes
Currently, our server logs provide limited information, making it difficult to diagnose issues and track user activity. So, I made Todos for better logging. Codes about custom log fields will be handled after LFX sync-up meeting and will be raised in the next pr.
Result
TODO
Issue No. #3932
Types of changes
What types of changes does your code introduce to Litmus? Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Dependency
Special notes for your reviewer: