P
Prisma•3mo ago
DennisK

Prisma Transactions stops working once you extend the client with Pulse, Optimize or Accelerate

See title. This stops me from migrating to these products and use in production. Once you extend the client and need to make a Prisma Transaction it will return an error and the transaction fails: TypeError: parentTracer.getSpanLimits is not a function
2 Replies
DennisK
DennisKOP•3mo ago
It is just so buggy. You need to extend the client like this in order to get $on and $transaction to work. But when you will do that, the Extensions are not being picked up by the LSP or even not functioning at all
const client = new PrismaClient({
log: [
{ level: 'query', emit: 'event' },
{ level: 'error', emit: 'stdout' },
{ level: 'warn', emit: 'stdout' },
],
})

client.$extends(withAccelerate())
client.$extends(
withPulse({
apiKey: process.env.PULSE_API_KEY,
}),
)
client.$extends(withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY }))

client.$on('query', async (e) => {
if (e.duration < logThreshold) return
const color =
e.duration < logThreshold * 1.1
? 'green'
: e.duration < logThreshold * 1.2
? 'blue'
: e.duration < logThreshold * 1.3
? 'yellow'
: e.duration < logThreshold * 1.4
? 'redBright'
: 'red'
const dur = chalk[color](`${e.duration}ms`)

console.info(`prisma:query - ${dur} - ${e.query}`)
})
const client = new PrismaClient({
log: [
{ level: 'query', emit: 'event' },
{ level: 'error', emit: 'stdout' },
{ level: 'warn', emit: 'stdout' },
],
})

client.$extends(withAccelerate())
client.$extends(
withPulse({
apiKey: process.env.PULSE_API_KEY,
}),
)
client.$extends(withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY }))

client.$on('query', async (e) => {
if (e.duration < logThreshold) return
const color =
e.duration < logThreshold * 1.1
? 'green'
: e.duration < logThreshold * 1.2
? 'blue'
: e.duration < logThreshold * 1.3
? 'yellow'
: e.duration < logThreshold * 1.4
? 'redBright'
: 'red'
const dur = chalk[color](`${e.duration}ms`)

console.info(`prisma:query - ${dur} - ${e.query}`)
})
Makes me really wonder if it's worth the risk paying for these products for a production grade app
RaphaelEtim
RaphaelEtim•3mo ago
Hi @DennisK 👋 Thank you for bringing this to our attention. The error TypeError: parentTracer.getSpanLimits is not a function appears to be caused by our implementation of open telemetry instrumentation as mentioned in this issue. A user mentioned here that updating @prisma/instrumentation to 5.13.0 fixed it for them. We are also working to fix this as well as can be seen in this PR
GitHub
feat(instrumentation)!: make otel deps peer dependencies by aqrln ·...
Make @opentelemetry/api a peer dependency and keep @opentelemetry/instrumentation a regular dependency in @prisma/instrumentation, as per the Instrumentations Implementation Guide. Also make @opent...
GitHub
parentTracer.getSpanLimits is not a function · Issue #21397 · pri...
Bug description Upgrading to Prisma v5.4.1 caused the following error to appear TypeError: parentTracer.getSpanLimits is not a function at new Span (/var/task/node_modules/@prisma/instrumentation/n...
GitHub
Instrumentation error in production: `TypeError: parentTracer.getSp...
Bug description I am attempting to connect to honeycomb.io with the new Prisma Telemetry options. In a dev environment this works just fine. But in production, I receive the following error: TypeEr...
Want results from more Discord servers?
Add your server