GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs

More Control over Error Logging

Offen
#484 4 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
enhancement P3
Vorherrschende Sprache
TypeScript
Sterne
1.4k
Forks
181
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.