Prisma opt-in with Nest.js doesn't work
See original GitHub issueEnvironment
SaaS (https://sentry.io/)
Version
Everything latest
Steps to Reproduce
I’m trying to configure performance monitoring with Nest.js and Prisma ORM. Followed the steps here but I only get the http span in the event, I don’t see any DB related spans.
I also tried to use the @prisma/instrumentation
package instead of the @prisma/client
which is used in the docs, but nothing seems to work.
schema.prisma
:
generator client {
provider = "prisma-client-js"
previewFeatures = ["tracing"]
}
This is my basic main.ts
file:
import { PrismaClient } from '@prisma/client';
import * as Sentry from '@sentry/node';
import * as Tracing from '@sentry/tracing';
import { ConfigService } from '@nestjs/config';
import { NestFactory } from '@nestjs/core';
import 'cross-fetch/polyfill'; // required for @microsoft/microsoft-graph-client
import dotenv from 'dotenv';
import AppModule from './app.module';
async function bootstrap() {
dotenv.config();
const app = await NestFactory.create(AppModule);
const httpAdapter = app.getHttpAdapter();
Sentry.init({
dsn: 'https://xxxxxx',
integrations: [
new Sentry.Integrations.Http({ tracing: true }),
new Tracing.Integrations.Express({
app: httpAdapter.getInstance(),
}),
new Tracing.Integrations.Prisma({ client: new PrismaClient() }),
],
tracesSampleRate: 1.0,
});
app
.use(Sentry.Handlers.requestHandler())
.use(Sentry.Handlers.tracingHandler())
.use(Sentry.Handlers.errorHandler());
await app.listen(app.get(ConfigService).get('PORT') || 3000);
}
// eslint-disable-next-line @typescript-eslint/no-floating-promises
bootstrap();
Expected Result
I should see DB spans in the transactions
Actual Result
Example event from sentry, without any DB span, only HTTP:
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
I get "Can't resolve '_http_common'" when I use NestJS with ...
When I try to composite Prisma with NestJS monorepo project I get the error. I can`t use default prisma client output path because...
Read more >Typescript not detecting Prisma optional fields - Stack Overflow
I'm creating seed files for my NestJS ...
Read more >Prisma | NestJS - A progressive Node.js framework
Prisma is an open-source ORM for Node.js and TypeScript. It is used as an alternative to writing plain SQL, or using another database...
Read more >Applying Full Stack Type Safety with Angular, Nest, Nx & Prisma
In this article, we'll look at how to apply type safety to every part of a full stack Angular and NestJS app, including...
Read more >Building a REST API with NestJS and Prisma - YouTube
In this hands-on workshop, you'll learn how to build a REST API with NestJS and the Prisma ORM in TypeScript.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We haven’t invested in a first class NestJS SDK - if you want to see that happen please let us know here: https://github.com/getsentry/sentry-javascript/discussions/5578. Backlogging this for now - but PRs welcome!
@AbhiPrasad yea I also tried to access the
PrismaService
and not the client, but same results. I guess someone in Sentry tested it with NestJs and Prisma and knows the best way to make it work, I would add it to the docs since it just doesn’t work the current way. What I did for now is adding to the$use
Prisma middleware a span withop: 'db.prisma'
after getting the transaction. It seems to work, but sounds like it should be better instrumented.