Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to use our Pino transport with pino.transport() #1146

Open
unflxw opened this issue Nov 11, 2024 · 0 comments
Open

Make it possible to use our Pino transport with pino.transport() #1146

unflxw opened this issue Nov 11, 2024 · 0 comments
Assignees
Labels

Comments

@unflxw
Copy link
Contributor

unflxw commented Nov 11, 2024

See also Slack conversation, Intercom conversation and Gist with workarounds.

It should be possible to use our Pino transport like the other transports documented in Pino's transport documentation:

pino(pino.transport({
  // this is an example, it's not the current location of the file
  target: '@appsignal/nodejs/pino',
  options: {...}
}))

This does not work with the current Pino transport, as it expects the client to be passed as the options, and the client is not serializable:

pino(pino.transport({
  target: '@appsignal/nodejs/dist/pino_transport.js',
  options: {
    // this fails, because the client is not serializable
    client: Appsignal.client,
    group: "pino"
  }
}))

This makes it really difficult to use it alongside other Pino transports, as described in Pino's documentation (e.g. to log to standard output as well as to AppSignal):

pino(pino.transport({
  targets: [
    { ... },
    // can't put AppSignal's transport here, see above
  ]
});

Instead, you have to know that it must be used as a destination and use pino.multistream() alongside pino.transport(), which is not documented as such anywhere:

pino(pino.multistream([
  { stream: AppsignalPinoTransport({ ... }) },
  { stream: pino.transport({ ... }) }
]));
@unflxw unflxw added the chore label Nov 11, 2024
@unflxw unflxw self-assigned this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant