gpt4 book ai didi

python - 为什么 Stackdriver 日志中会间歇性地出现空行?

转载 作者:行者123 更新时间:2023-12-04 21:28:39 26 4
gpt4 key购买 nike

我每分钟都在运行一个云功能。

空行(请参阅下面的日志)间歇性地出现在 Stackdriver 日志中。

我不相信这是由于我编写的函数代码。

可以使用这个 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")

当 Cloud Scheduler 每分钟触发一次时,此函数会在几个小时内发出空行。

如何防止这个问题?

更新:添加了两个扩展日志
{
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

最佳答案

同时,您可以向 stackdriver 添加过滤器以跳过带有空字符串的日志。

关于python - 为什么 Stackdriver 日志中会间歇性地出现空行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58983677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com