Optimize is not showing queries

I've been trying to get optimize to work since it first launched in beta, but queries just don't show up in the dashboard. i'm not sure how to get more logging...
32 Replies
Nurul
Nurul4mo ago
Do you get any errors while trying to use Optimize?
samuelcole
samuelcoleOP4mo ago
none at all the app works, the prompt+notification to go to the optimize dashboard pops up just nothing shows up in the dashboard random clues: i already love open telemetry, and we have our own instrumentation registered (but i believe i tried removing it, and there were no changes) we are a monoropo running on turbo, prisma is imported from a shared project, and is using singleton pattern
DennisK
DennisK4mo ago
I have the same
brookmg
brookmg4mo ago
I have been facing the same issue since the beta. Not sure why it's not working either Is there a flag to pass to make it log its issues?
Papa Smerf
Papa Smerf4mo ago
Soo for me recording catch only create/delete queries all select queries are omitted.
brookmg
brookmg4mo ago
Is that how it works normally? I'm using main / replica setup using @prisma/extension-read-replicas extension as well. Not sure if that's affecting it somehow. @Nurul (Prisma)
Papa Smerf
Papa Smerf4mo ago
Nope that was my fault. There is a section about data that should be captured by recording
No description
Papa Smerf
Papa Smerf4mo ago
Also good to know if some of the queries are not shown you should try to change the order of extends e.g first you use optimize then accelerate
brookmg
brookmg4mo ago
I don't use the other services. I did attempt changing the order of extends but no luck What flag can we use to make optimize log verbose?
Papa Smerf
Papa Smerf4mo ago
Maybe this will help you https://www.prisma.io/docs/optimize/known-limitations. At the bottom is Driver adapter compatibility and that can cause problems
brookmg
brookmg4mo ago
Well I'm using the client as is, there is no driver adapter involved.
Nurul
Nurul4mo ago
@samuelcole @DennisK @brookmg Are your projects in which you are trying to use optimize open source? Would it be possible to share a minimal reproduction so that we can figure out what's going on?
DennisK
DennisK4mo ago
Nope sorry, it is not OS.
Nurul
Nurul4mo ago
We have released a new optimize extension version 1.0.1 which fixes a bunch of issues. Can you try using the new version and check if your issue gets resolved? https://www.npmjs.com/package/@prisma/extension-optimize
npm
@prisma/extension-optimize
This is the package for the Prisma Client extension, which enables the use of Prisma Optimize.. Latest version: 1.0.1, last published: 36 minutes ago. Start using @prisma/extension-optimize in your project by running `np...
brookmg
brookmg4mo ago
Sadly can't share the codebase but the lastest update isn't working either. 1.0.1.
export const MClient = new PrismaClient({
log: [
{ emit: "stdout", level: "info" },
{ emit: "stdout", level: "warn" },
{ emit: "stdout", level: "error" },
{ emit: "event", level: "query" },
],
}).$extends(
withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY }),
).$extends(readReplicas({
url: process.env.DATABASE_URL_REPLICA,
}));
export const MClient = new PrismaClient({
log: [
{ emit: "stdout", level: "info" },
{ emit: "stdout", level: "warn" },
{ emit: "stdout", level: "error" },
{ emit: "event", level: "query" },
],
}).$extends(
withOptimize({ apiKey: process.env.OPTIMIZE_API_KEY }),
).$extends(readReplicas({
url: process.env.DATABASE_URL_REPLICA,
}));
This is how I currently configured it but nothing shows up on the dashboard
Nurul
Nurul4mo ago
Thanks for letting me know. Can you try without readReplicas extension and check if something shows up in the dashboard?
samuelcole
samuelcoleOP4mo ago
1.0.1 isn’t working for me either, and I don’t use readReplicas Do we all use next.js by any chance? This is a next app
Nurul
Nurul4mo ago
Oh Okay! Is your app open source by any chance samuel?
samuelcole
samuelcoleOP4mo ago
it is not 😕 also i would like to reiterate that i would love an additional logging level, so that i can see under the hood a bit, to see if there's any clues there
trevor_h.
trevor_h.4mo ago
Same issue here. Everything runs but no queries show in optimize console. Was able to get it working.. Found that we weren't using the read replica extension, but we were instantiating a separate PrismaClient with the datasources option set: { datasources: { db: { url: config.PRISMA_READ_URL } } } This caused the issue..
Eric
Eric3mo ago
I have the same issue (also a private repo so can not share). I've followed the instructions and set everything up, I see See your Optimize dashboard at: https://optimize.prisma.io in the console, hit record, and nothing showing up as I play around in my app. Any updates @Nurul (Prisma) ?
Jana
Jana2mo ago
Was this issue resolved? I am getting the same (empty results) with the latest version - 1.0.1 🙈
Nurul
Nurul2mo ago
Can you check if the example I shared in this thread works for you? https://discord.com/channels/937751382725886062/1270167207204356178/1270167207204356178
diginikkari
diginikkari2mo ago
@Nurul I had the same issue with optimize not showing any queries. In our case I found out that the issue was that optimize doesn’t work when there is sentry node profiling configured. Is there some issue tracking where thisissue could be posted?
Nurul
Nurul2mo ago
Hey @diginikkari I wasn't aware about the issue with sentry node profiling. Do you mind creating an issue? https://github.com/prisma/optimize-feedback/issues I'll share it internally with our Optimize team 🙏
diginikkari
diginikkari2mo ago
Hi @Nurul Sure, I created issue with reproduction repo linked: https://github.com/prisma/optimize-feedback/issues/18
GitHub
Optimize not recording any queries when there is Sentry node profil...
Describe the bug When configuring Prisma Optimize to app where also Sentry is used, optimize doesn't record any queries. To Reproduce Steps to reproduce the behavior. I have created minimal rep...
nanou
nanou2mo ago
Hey I'm experiencing the same issue with a raw config, nothing shows in my dashboard 😉
_patatinabollente
Same issue here, I am using Nest js. Maybe it has something to do with extension initialization in my case
Nurul
Nurul2mo ago
@nanou @_patatinabollente Do you mind sharing a minimal reproduction with us?
_patatinabollente
Hi, I have followed the instruction so
npm install @prisma/client@latest @prisma/extension-optimize@latest
npm install --save-dev prisma@latest
npm install @prisma/client@latest @prisma/extension-optimize@latest
npm install --save-dev prisma@latest
Here is my prisma schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
binaryTargets = ["native", "linux-musl"]
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
binaryTargets = ["native", "linux-musl"]
}
Then I extended my prisma client
const customPrismaClient = new PrismaClient().$extends(
withOptimize({
apiKey
})
);

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit(): Promise<void> {
Object.assign(this, customPrismaClient);
await this.$connect();
}
}
const customPrismaClient = new PrismaClient().$extends(
withOptimize({
apiKey
})
);

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit(): Promise<void> {
Object.assign(this, customPrismaClient);
await this.$connect();
}
}
I think the issue could be this extension on Nest js but I've tried all the examples on https://github.com/prisma/prisma/issues/18628 and nothing seems to work for me. The related issue is relative to maintaining type safety while extending prisma client. I do not think is necessary in this case. For context i am using nest 9 (tried also with 10, no difference) and node 18 (also here tried with 20 no difference) Hope it helps Thanks
GitHub
Ability to extend PrismaClient class w/ Client Extensions before ...
Problem Within NestJS, the common solution to implementing an injectable Prisma Client instance is to extend PrismaClient and add the onModuleInit and enableShutdownHooks functions required by Nest...
nanou
nanou2mo ago
export let prismaEvents = new PrismaClient()
.$extends(
readReplicas({
url: config.EVENTS_DATABASE_READ_REPLICA_URL,
})
)
.$extends(
withOptimize({
apiKey: config.OPTIMIZE_EVENTS_API_KEY ?? "",
enable: true,
})
);
export let prismaEvents = new PrismaClient()
.$extends(
readReplicas({
url: config.EVENTS_DATABASE_READ_REPLICA_URL,
})
)
.$extends(
withOptimize({
apiKey: config.OPTIMIZE_EVENTS_API_KEY ?? "",
enable: true,
})
);
With :
"@prisma/client": "5.21.1",
"@prisma/extension-optimize": "latest",
"@prisma/extension-read-replicas": "0.3.0",
"@prisma/client": "5.21.1",
"@prisma/extension-optimize": "latest",
"@prisma/extension-read-replicas": "0.3.0",
And without any error in the console (except if I pass an empty API_KEY)
Nurul
Nurul2mo ago
What happens if you test without the readReplicas?
Want results from more Discord servers?
Add your server