Socket
Book a DemoInstallSign in
Socket

@bonniernews/gcp-trace-logging-correlator

Package Overview
Dependencies
Maintainers
33
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bonniernews/gcp-trace-logging-correlator

Helps you correlate both request and application logs in an app running on GCP

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
33
Created
Source

gcp-trace-logging-correlator

Helps you correlate both request and application logs in an app running on GCP. You can read more about log correlation in GCP here https://cloud.google.com/run/docs/logging#correlate-logs

Installation

npm install @bonniernews/gcp-trace-logging-correlator

Usage

This package comes with an express middleware and a function that extracts the trace as an object that should be injected into your logs.

Install the middleware somewhere globally in your app. You have to provide the GCP project ID meaning you probably want to set this up with an environment variable.

import { middleware } from "@bonniernews/gcp-trace-logging-correlator";

// ...

app.use(middleware(config.get("gcp_project_id")));

You should then provide the object returned by the function getTraceObject to your logging library. If you're using pino, you should pass it to a mixin like this

import { getTraceObject } from "@bonniernews/gcp-trace-logging-correlator";

const logger = pino({
  // ...
  mixin = () => ({
    somethingElse: "foo",
    ...getTraceObject(),
  });
});

Keywords

gcp

FAQs

Package last updated on 08 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts