GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs
More Control over Error Logging
- Ngôn ngữ chính
- TypeScript
- Star
- 1.4k
- Fork
- 181
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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!
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với các đường dẫn lỗi trong src/function_wrappers.ts và src/logger.ts được liên kết từ issue, sau đó xem xét việc xử lý CloudEventFunction và các yêu cầu về ghi log có cấu trúc. Được coi là hoàn tất khi framework cung cấp một cách thức rõ ràng để kiểm soát việc ghi log lỗi hoặc đánh dấu một yêu cầu là thất bại mà không throw, không tạo các mục lỗi trùng lặp hoặc bị tách thành nhiều phần.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- google-cloud, nodejs, typescript
- Lĩnh vực
- backend, cloud, observability
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100