Skip to content

Conversation

@cre8ivejp
Copy link
Member

@cre8ivejp cre8ivejp commented Oct 27, 2025

Fix #2169

@cre8ivejp cre8ivejp changed the title chore: reduce cronjob log verbosity with structured logging chore: reduce info log verbosity with structured logging Oct 27, 2025
Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
Comment on lines +71 to +75
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}'"}'
Copy link
Member Author

@cre8ivejp cre8ivejp Oct 27, 2025

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."
Copy link
Member Author

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.

@cre8ivejp cre8ivejp marked this pull request as ready for review October 27, 2025 10:20
Comment on lines +26 to +27
app: {{ template "batch-server.name" $ }}
job-type: cronjob
Copy link
Member Author

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.

Copy link
Collaborator

@Ubisoft-potato Ubisoft-potato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@cre8ivejp cre8ivejp merged commit 41d5a0f into main Oct 27, 2025
17 checks passed
@cre8ivejp cre8ivejp deleted the chore-info-logs branch October 27, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: reduce info log verbosity with structured logging

3 participants