Add Official Sentry NestJS SDK/Integration #5578
Replies: 12 comments 29 replies
-
An official sdk would be great, especially since https://github.com/ntegral/nestjs-sentry seems to have been abandoned. |
Beta Was this translation helpful? Give feedback.
-
Yeah, an official SDK it's really necessary, maybe work with the nestjs team and do something like they have done with @nestjs/typeorm & @nestjs/mongoose... My use case: Any eta for that? |
Beta Was this translation helpful? Give feedback.
-
What about trying to transfer ntegral/nestjs-sentry to nestjs org first and to let the community drive the change first? Then if sentry team has the bandwidth later, sentry team could also chime in. |
Beta Was this translation helpful? Give feedback.
-
This would be really great. Just want to chime in that currently, none of the Sentry tracing (APM) integrations work when running from a NestJS app. Example: Sentry.init({
dsn: '<redacted>',
tracesSampleRate: 1.0,
integrations: [
new Tracing.Integrations.Express({ app: app.getHttpAdapter().getInstance() }),
new Tracing.Integrations.Apollo(),
new Tracing.Integrations.Prisma({ client: app.get(PrismaService) }),
],
}); ^ Running in a NestJS application where |
Beta Was this translation helpful? Give feedback.
-
Tried |
Beta Was this translation helpful? Give feedback.
-
Yeah I am not getting this working properly with async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
const port = configService.get<number>('app.port');
const node_env = configService.get<string>('app.environment');
const dsn = configService.get<string>('sentry.dsn');
Sentry.init({
environment: node_env,
dsn,
debug: true,
});
console.log(node_env, dsn); // this logs out correctly
app.enableCors();
app.getHttpAdapter().getInstance().disable('x-powered-by');
Sentry.setupNestErrorHandler(app);
console.log(`application starting on port ${port}`);
await app.listen(port);
} And it looks like Sentry starts up correctly however whenever there is an error the request just hangs and I get the following debug message:
Which likely has nothing to do with the fact that the api hangs and does not respond with an error. As soon as I remove |
Beta Was this translation helpful? Give feedback.
-
Is GraphQL supported? I am testing version {
"errors": [
{
"message": "Cannot read properties of undefined (reading 'route')",
"locations": [
{
"line": 2,
"column": 5
}
],
"path": [
"me"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"TypeError: Cannot read properties of undefined (reading 'route')",
" at Object.intercept (/workspaces/project/node_modules/@sentry/src/integrations/tracing/nest.ts:61:15)",
" at nextFn (/workspaces/project/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:23:36)",
" at /workspaces/project/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:25:40",
" at Observable._subscribe (/workspaces/project/node_modules/rxjs/src/internal/observable/defer.ts:55:15)",
" at Observable._trySubscribe (/workspaces/project/node_modules/rxjs/src/internal/Observable.ts:244:19)",
" at /workspaces/project/node_modules/rxjs/src/internal/Observable.ts:234:18",
" at Object.errorContext (/workspaces/project/node_modules/rxjs/src/internal/util/errorContext.ts:29:5)",
" at Observable.subscribe (/workspaces/project/node_modules/rxjs/src/internal/Observable.ts:220:5)",
" at Object.mergeInternals (/workspaces/project/node_modules/rxjs/src/internal/operators/mergeInternals.ts:136:10)",
" at /workspaces/project/node_modules/rxjs/src/internal/operators/mergeMap.ts:95:42"
]
}
}
],
"data": {
"me": null
}
} main.ts import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as Sentry from '@sentry/node';
async function bootstrap() {
Sentry.init({
environment: process.env.NODE_ENV,
dsn: process.env.SENTRY_DSN,
debug: true,
});
const app = await NestFactory.create(AppModule, {});
Sentry.setupNestErrorHandler(app);
await app.listen(3000);
}
bootstrap(); user.resolver.ts @Query(() => UserEntity, { nullable: true })
@UseGuards(AuthGuard)
me(@CurrentUser() user: User): User {
throw new Error('My error');
return user;
} |
Beta Was this translation helpful? Give feedback.
-
Will it support tracing? And will it give tracing & error handling to packages such as https://docs.bullmq.io/guide/nestjs as well? |
Beta Was this translation helpful? Give feedback.
-
I'm testing |
Beta Was this translation helpful? Give feedback.
-
Also, it doesn't seem to work when using Fastify with NestJS. https://docs.nestjs.com/techniques/performance const app = await NestFactory.create<NestFastifyApplication>(module, new FastifyAdapter({ logger: true }));
Sentry.setupNestErrorHandler(app, new BaseExceptionFilter(app.getHttpAdapter()));
|
Beta Was this translation helpful? Give feedback.
-
I recently switched from ntegral/nestjs-sentry to official sentry node sdk with NestJs support. I have done that minimal configuration of Is there anything else to be done to enable performance monitoring apart from changes in those two files? |
Beta Was this translation helpful? Give feedback.
-
There is now official Sentry Nest.js support as part of https://docs.sentry.io/platforms/javascript/guides/nestjs/ Closing this conversation as a result. If you experience any bugs or have feature requests, please open a new GitHub issue. Thank you to everyone who helped test this during our alpha/beta and gave us advice on how the integration should work. |
Beta Was this translation helpful? Give feedback.
-
Update:
Improved NestJS support was delivered as part of JS SDK
v8.x
. But we decided to not stop there, our official@sentry/nestjs
SDK is already under development. Follow along here and let us hear your feedback!@ntegral has done some great work on a community supported SDK for the NestJS framework: https://github.com/ntegral/nestjs-sentry
We can probably build on top of that and release an officially supported NestJS SDK/Integration. Not sure if it should be it's own SDK, or a standalone integration atm - we'll see when we investigate further.
We'll need to make sure we have:
All powered by our Node JS SDK -
@sentry/node
.Please comment/react to this post if you would like to see this - that helps us prioritize this work.
Beta Was this translation helpful? Give feedback.
All reactions