Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do empty lines appear intermittently in Stackdriver logs?

I'm running a cloud function every minute.

Blank lines (see logs below) appear in Stackdriver logs intermittently.

I don't believe this is due to the function code I have written.

Bug can be recreated with this main.py:

import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.info(f"Logging {__name__}")


def main(event, context):
    logger.info("Message 1")
    logger.info("Message 2")
    logger.info("Message 3")

This function emitted blanks lines within a couple hours when triggered every minute by Cloud Scheduler.

How can this issue be prevented?

Update: Added two expanded logs

{
 insertId: "000001-redacted-but-identical"  
 labels: {
  execution_id: "894004659398898"   
 }
 logName: "projects/redacted/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp: "2019-12-13T23:05:01.545007423Z"  
 resource: {
  labels: {
   function_name: "recreate_blank_lines"    
   project_id: "redacted"    
   region: "us-central1"    
  }
  type: "cloud_function"   
 }
 severity: "INFO"  
 timestamp: "2019-12-13T23:05:00.344Z"  
 trace: "projects/redacted/traces/c4ed0267fd9fa4bf9133043bdfe5b1e0"  
}

{
 insertId: "000000-redacted-but-identical"  
 labels: {
  execution_id: "894004659398898"   
 }
 logName: "projects/redacted/logs/cloudfunctions.googleapis.com%2Fcloud-functions"  
 receiveTimestamp: "2019-12-13T23:05:01.545007423Z"  
 resource: {
  labels: {
   function_name: "recreate_blank_lines"    
   project_id: "redacted"    
   region: "us-central1"    
  }
  type: "cloud_function"   
 }
 severity: "INFO"  
 textPayload: "Message 2"  
 timestamp: "2019-12-13T23:05:00.345Z"  
 trace: "projects/redacted/traces/c4ed0267fd9fa4bf9133043bdfe5b1e0" 

Blank log example

Blank log example 2

like image 911
ProGirlXOXO Avatar asked Nov 07 '22 11:11

ProGirlXOXO


1 Answers

In the meantime, you can add a filter to stackdriver to skip logs with empty strings.

like image 57
marcos Avatar answered Nov 14 '22 21:11

marcos