-
Notifications
You must be signed in to change notification settings - Fork 694
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
Use logrus for structured logging #416
Conversation
nit: Could you include some sample log output in the PR description? |
Does the log output include line number or just filename? |
Added sample log output. The log output includes line numbers as well. |
Thanks for your contribution 🎉 There is two concerns:
|
/retest |
/assign jlewi |
@gaocegege That's a good point about vendor and generated code. I don't think we should try to update those packages manually; that seems like a burden to maintain long term. I think it should be fine to intersperse json and not json log entries. Hopefully logging backends are sophisticated enough to deal with this. The motivation for using structured logging is so that we can add fields to the log from our code so that we can easily search for logs pertaining to a particular job, replica, index, etc... I think this will really help us to debug issues. A lot of the bugs we get are of the form I expected X to happen for job Y but it did not. So we'd like to know what the operator was doing for job Y. But if a lot of jobs are running finding the relevant logs for a particular job can be diffcult. @ankushagarwal Can you open up a follow on issue to add such labels to the operator. |
Created #424 |
* Move from glog to sirupsen/logrus for logging * Add a new flag json_log_format * Refactor all log statements to use logrus * Use Info level for log level V(1) and below * Use Debug level for log level V(2) and above Addresses #24
I'd suggest resyncing to see if that fixes the tests. |
/retest |
I will have a try and submit my review today. |
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.
There are somethings:
- Code in
pkg/clientset
is changed in the PR, and I think we should not do it manually, so please revert the changes by./hack/update-codegen.sh
tf-operator -version
returns some useless logs
./tf-operator -version
{"filename":"app/server.go:54","level":"info","msg":"EnvKubeflowNamespace not set, use default namespace","time":"2018-03-01T09:57:27+08:00"}
{"filename":"app/server.go:59","level":"info","msg":"[Version: 0.3.0+git Git SHA: Not provided. Go Version: go1.8.3 Go OS/Arch: linux/amd64]","time":"2018-03-01T09:57:27+08:00"}
Version: 0.3.0+git
Git SHA: Not provided.
Go Version: go1.8.3
Go OS/Arch: linux/amd64
It is ok to ignore the second one since it is not in high priority.
I have observation to share with you @ankushagarwal @jlewi , I am not sure how to deal with it. Now we use flag package to support command line flags, and glog also uses it by default. Then you can see our binary have more flags than we thing although we use logrus instead of glog:
There are some pros and cons:
We could discuss it in the issue, not in the PR. After the client is regenerated the PR LGTM |
@gaocegege I have changed I have fixed the |
/approve pkg/client is all auto-generated by kubernetes/code-generator. update-codegen.sh works for me, it seems that the script uses the wrong code-generator in kubernetes repo. But no worry about it, I can open a PR to fix the clientset. Thanks for your awesome contribution and patience! The log problem has been bothering us for long time. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gaocegege, jlewi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Sorry, the CI failed because we use Could you fix it? |
@gaocegege : Can you link me to the failure? We use both |
Added sirupsen/logrus as a glide dependency - hopefully build should pass now |
/retest |
* Move from glog to sirupsen/logrus for logging * Add a new flag json_log_format * Refactor all log statements to use logrus * Use Info level for log level V(1) and below * Use Debug level for log level V(2) and above * Tested locally Addresses kubeflow#24 Sample logs ``` {"filename":"app/server.go:54","level":"info","msg":"EnvKubeflowNamespace not set, use default namespace","time":"2018-02-27T18:25:18-08:00"} {"filename":"app/server.go:59","level":"info","msg":"[Version: 0.3.0+git Git SHA: Not provided. Go Version: go1.9.3 Go OS/Arch: darwin/amd64]","time":"2018-02-27T18:25:18-08:00"} {"filename":"app/server.go:145","level":"info","msg":"No controller_config_file provided; using empty config.","time":"2018-02-27T18:25:18-08:00"} {"filename":"controller/controller.go:110","level":"info","msg":"Setting up event handlers","time":"2018-02-27T18:25:18-08:00"} ```
Addresses #24
Sample logs
This change is