Content-Length: 277019 | pFad | http://github.com/getsentry/sentry-javascript/issues/16723

61 Make pino transport work with worker threads · Issue #16723 · getsentry/sentry-javascript · GitHub
Skip to content

Make pino transport work with worker threads #16723

Open
@AbhiPrasad

Description

@AbhiPrasad

Description

pino transports run in a worker thread. This means we have to send logs via the pino transport, we need to re-initialize sentry in the worker thread. This also means that the trace ids from the worker thread will be different than the trace ids in sentry.

We can get the trace id part working via usage of https://www.npmjs.com/package/@opentelemetry/instrumentation-pino.

The main blocker then becomes initializing the Sentry SDK. The approach every other vendor takes here is to just allow people to pass in sentry config and initialize the SDK within the pino transport. This might be a bit confusing to users.

Another alternative is the following:

  1. Construct a pino logger instance, but point it toward another file:
// in main application

// Create a pino logger instance
const logger = pino({
  name: "pino-demo",
  level: "debug",
  transport: {
    target: "./pino-transport.mjs",
  },
});
  1. In that seperate file we initialize the SDK and return the pino transport:
// filename: pino-transport.mjs

import * as Sentry from "@sentry/node";

Sentry.init({
  debug: true,
  dsn: "PUBLIC_DSN",
  _experiments: {
    enableLogs: true,
  },
});

import { createSentryPinoTransport } from "@sentry/pino-transport";

export default createSentryPinoTransport;

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: http://github.com/getsentry/sentry-javascript/issues/16723

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy