pino-datadog-transport with Next.js on Vercel

Viewed 69

I'm trying to migrate a Next.js project running on Vercel from

    "pino-datadog": "2.0.2",
    "pino-multi-stream": "6.0.0",

to

    "pino": "8.4.2",
    "pino-datadog-transport": "1.2.2",

and I copy the setup from the pino-datadog-transport's README.md:

import { LoggerOptions, pino } from 'pino'

const pinoConf: LoggerOptions = {
  level: 'trace',
}

const logger = pino(
  pinoConf,
  pino.transport({
    target: 'pino-datadog-transport',
    options: {
      ddClientConf: {
        authMethods: {
          apiKeyAuth: process.env.DATADOG_API_KEY,
        },
      },
      ddServerConf: {
        site: 'datadoghq.eu',
      },
      service: process.env.VERCEL_URL
      ddsource: 'nodejs',
    },
  }),
)

and this seems to be working fine locally, but when I publish it on Vercel and run it there I get the following error:

ERROR   Error: unable to determine transport target for "pino-datadog-transport"
    at fixTarget (/var/task/node_modules/pino/lib/transport.js:136:13)
    at Function.transport (/var/task/node_modules/pino/lib/transport.js:110:22)

Am I missing some additional config to get this working? Anyone else running this setup or something similar to get explicit logs working on Vercel with Next.js?

I have enabled the Datadog integration in Vercel as well, but that only forwards Next.js logs, not explicit console.logs or standard Pino logs from what I can tell.

0 Answers
Related