You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Logging] Create and add structured logs for Cleanup task (#4781)
### 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](https://cloud.google.com/python/docs/reference/logging/latest/std-lib-integration#automatic-metadata-detection)).
(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.
* Setting `IS_K8S_ENV` to true ([link to
logs](https://cloudlogging.app.goo.gl/Us8aHBMUyNoaPFbL8)):

0 commit comments