- 
                Notifications
    You must be signed in to change notification settings 
- Fork 23
chore: reduce info log verbosity with structured logging #2168
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
Conversation
ba5cb4d    to
    478b3bb      
    Compare
  
    Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
478b3bb    to
    1ea358a      
    Compare
  
    | echo '{"severity":"DEBUG","message":"'${JOB_NAME}' job completed successfully","job":"'${JOB_NAME}'","jobId":"'${JOB_ID}'","statusCode":'${RES}',"durationSeconds":'${DURATION}'}' | ||
| else | ||
| # Failure - log as ERROR with response details for debugging | ||
| BODY_ESCAPED=$(echo "${BODY}" | sed 's/\\/\\\\/g; s/"/\\"/g' | tr '\n\r\t' ' ') | ||
| echo '{"severity":"ERROR","message":"'${JOB_NAME}' job failed","job":"'${JOB_NAME}'","jobId":"'${JOB_ID}'","statusCode":'${RES}',"durationSeconds":'${DURATION}',"responseBody":"'${BODY_ESCAPED}'"}' | 
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.
The debug logs were always reported as INFO level to GCP, so I formatted them using JSON format.
| args: | ||
| - -c | ||
| - | | ||
| echo "Start {{ .name }} job." | 
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.
I removed the start log and implemented the elapsed time to be reported in the success log.
| app: {{ template "batch-server.name" $ }} | ||
| job-type: cronjob | 
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.
Implemented it to report the logs as batch-server for easy tracking on the GCP console.
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! 🚀
Fix #2169