Skip to content

Prisma opt-in with Nest.js doesn't work #5656

@tomgrossman

Description

@tomgrossman

Environment

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:

image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions