Skip to content

Is it okay to not use await for a log.write() promise inside a container in Cloud Run?

Yes, the documentation for Cloud Logging says that for high-performance applications, you should avoid waiting for log.write promises.

ts
await log.write(logEntry1);
await log.write(logEntry2);

Instead, applications should use the "fire and forget" mechanism.

ts
log.write(logEntry1);
log.write(logEntry2);

This is because the @google-cloud/logging library will take care of processing the batches and sending the log lines to the API.