GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs
More Control over Error Logging
- 主要语言
- 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.

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