Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Logging] Create and add structured logs for Cleanup task #4781

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ViniciustCosta
Copy link
Collaborator

@ViniciustCosta ViniciustCosta commented Apr 30, 2025

Description

Adding structured logging to the cleanup cronjob. In order to enable this, the following changes on logs module were done:

  • Added a new log context for cronjobs.
  • Added a filter to the logs handler for both GAE/GKE to propagate the extras argument from python logging to the json_fields metadata in google cloud logging (GCP reference). (Note that this is a workaround to enable the observability project for now. As a long-term solution, we should try to centralize the logs handlers/filters for all environments).

For the cleanup module:

  • Set env vars for task name and ID in the cron entrypoints (for k8s and appengine).
  • Instrumented the cleanup code with the cron-based log context and with the testcase-based context. This latest is done for each testcase within the clean up unneeded open testcases method.

Tests

Running the cronjob locally with the debugger and sending logs to GCP.

@ViniciustCosta ViniciustCosta marked this pull request as ready for review May 6, 2025 13:39
@@ -59,6 +60,11 @@ def main():
task = sys.argv[1]

task_module_name = f'clusterfuzz._internal.cron.{task}'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make a standard function to do this rather than reimplementing it?

Copy link
Collaborator Author

@ViniciustCosta ViniciustCosta May 6, 2025

Choose a reason for hiding this comment

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

Done, thanks!

Copy link
Collaborator

@jonathanmetzman jonathanmetzman left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants