GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs

More Control over Error Logging

未关闭
#484 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
enhancement P3
主要语言
TypeScript
星标
1.4k
派生
181
PR 合并指标
30 天内没有已合并 PR

描述

Hello, I started using `@google-cloud/functions-framework` and noticed that it is not much compatible with [structured logging](https://cloud.google.com/logging/docs/structured-logging).

Especially, when I use [the CloudEventFunction style](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/db922c08687e7eec124ff0d696e0e60d6bf41df8/src/function_registry.ts#L91) which seems to be the [recommended way when integrating with Cloud Pub/Sub](https://cloud.google.com/functions/docs/tutorials/pubsub), the function must throw in order to mark the request as failed (i.e. [respond with 500](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/db922c08687e7eec124ff0d696e0e60d6bf41df8/src/logger.ts#L51)).

In that case, the default (and inevitable) error logging isn't quite nice. First, error is logged twice 😨 ([1](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/db922c08687e7eec124ff0d696e0e60d6bf41df8/src/function_wrappers.ts#L51), [2](https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/db922c08687e7eec124ff0d696e0e60d6bf41df8/src/logger.ts#L40)). Second, neither log is not structured, resulting in the error log being split into multiple entries.

![スクリーンショット 2022-11-16 17 01 55](https://user-images.githubusercontent.com/748348/202125268-604bef97-567d-4d41-aea3-fe1c9e596129.png)

I would like to get more control over how errors are logged. Or, maybe as another solution, a method for marking the request as failed without throwing will satisfy my use case.

Thanks!

贡献指南

打开贡献指南

调研方向

先从 issue 中链接的 src/function_wrappers.ts 和 src/logger.ts 中的错误路径开始,然后检查 CloudEventFunction 处理和结构化日志记录要求。当框架提供一种明确的方式来控制错误日志记录,或在不抛出异常的情况下将请求标记为失败,且不会产生重复或拆分的错误条目时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
google-cloud, nodejs, typescript
领域
backend, cloud, observability
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。