broadinstitute / genetic-prevalence-estimator

https://genie.broadinstitute.org/
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Configure structured logging #65

Closed nawatts closed 1 year ago

nawatts commented 2 years ago

Log messages should be formatted so that Cloud Logging understands them. Currently, multi-line log messages are treated as different messages.

https://cloud.google.com/logging/docs/structured-logging

nawatts commented 2 years ago

https://cloud.google.com/blog/products/devops-sre/google-cloud-logging-python-client-library-v3-0-0-release

nawatts commented 1 year ago

This seems to be working well out of the box for internal server errors on the website, but multi-line log messages from the worker are still split across multiple log entries.

nawatts commented 1 year ago

This was easier than I thought, since on Cloud Run we can use StructuredLogHandler to format logs as JSON instead of the default CloudLoggingHandler which has a client that communicates with Cloud Logging services.

https://github.com/broadinstitute/genetic-prevalence-estimator/blob/86903d0056e0b6bb42ee36646884b0c9fc8fe76c/worker/src/worker/settings/production.py#L6-L17