From 182002cb75091a3a4870bda10a393455e307543d Mon Sep 17 00:00:00 2001 From: Niel Markwick Date: Mon, 9 Dec 2024 13:20:59 +0100 Subject: [PATCH] chore(docs): add links to gcp logging formatter (#2088) Co-authored-by: nielm --- docs/ecosystem.md | 1 + docs/help.md | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/ecosystem.md b/docs/ecosystem.md index 2e62e9ae1..5356dc0a2 100644 --- a/docs/ecosystem.md +++ b/docs/ecosystem.md @@ -68,6 +68,7 @@ according to a given format string. ## Community ++ [`@google-cloud/pino-logging-gcp-config`](https://www.npmjs.com/package/@google-cloud/pino-logging-gcp-config): Config helper and formatter to output [Google Cloud Platform Structured Logging](https://cloud.google.com/logging/docs/structured-logging) + [`@newrelic/pino-enricher`](https://github.com/newrelic/newrelic-node-log-extensions/blob/main/packages/pino-log-enricher): a log customization to add New Relic context to use [Logs In Context](https://docs.newrelic.com/docs/logs/logs-context/logs-in-context/) + [`cloud-pine`](https://github.com/metcoder95/cloud-pine): transport that provides abstraction and compatibility with [`@google-cloud/logging`](https://www.npmjs.com/package/@google-cloud/logging). + [`cls-proxify`](https://github.com/keenondrums/cls-proxify): integration of pino and [CLS](https://github.com/jeff-lewis/cls-hooked). Useful for creating dynamically configured child loggers (e.g. with added trace ID) for each request. diff --git a/docs/help.md b/docs/help.md index 383f88873..90f2dd31f 100644 --- a/docs/help.md +++ b/docs/help.md @@ -260,6 +260,32 @@ module.exports = function createLogger(options) { } ``` +A library that configures Pino for +[Google Cloud Structured Logging](https://cloud.google.com/logging/docs/structured-logging) +is available at: +[@google-cloud/pino-logging-gcp-config](https://www.npmjs.com/package/@google-cloud/pino-logging-gcp-config) + +This library has the following features: + ++ Converts Pino log levels to Google Cloud Logging log levels, as above ++ Uses `message` instead of `msg` for the message key, as above ++ Adds a millisecond-granularity timestamp in the + [structure](https://cloud.google.com/logging/docs/agent/logging/configuration#timestamp-processing) + recognised by Google Cloud Logging eg: \ + `"timestamp":{"seconds":1445470140,"nanos":123000000}` ++ Adds a sequential + [`insertId`](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#FIELDS.insert_id) + to ensure log messages with identical timestamps are ordered correctly. ++ Logs including an `Error` object have the + [`stack_trace`](https://cloud.google.com/error-reporting/docs/formatting-error-messages#log-error) + property set so that the error is forwarded to Google Cloud Error Reporting. ++ Includes a + [`ServiceContext`](https://cloud.google.com/error-reporting/reference/rest/v1beta1/ServiceContext) + object in the logs for Google Cloud Error Reporting, auto detected from the + environment if not specified ++ Maps the OpenTelemetry properties `span_id`, `trace_id`, and `trace_flags` + to the equivalent Google Cloud Logging fields. + ## Using Grafana Loki to evaluate pino logs in a kubernetes cluster @@ -316,4 +342,4 @@ if you have broader logging requirements. ## Testing -See [`pino-test`](https://github.com/pinojs/pino-test). \ No newline at end of file +See [`pino-test`](https://github.com/pinojs/pino-test).