This module allows to use the following features of the sentry.
- Error issues reporting
- Performance
- Profiling
npm install --save-dev @comfortable-typescript/nestjs-sentry
import { SentryModule } from '@comfortable-typescript/nestjs-sentry';
@Module({
imports: [
SentryModule.forRoot({
// @see https://docs.sentry.io/platforms/node/configuration/options
dsn: 'https://dsn.sentry.io',
tracesSampleRate: 1,
}),
RootModule,
ConsumerModule,
],
controllers: [],
providers: [],
})
export class AppModule {}
- Include SentrycingModule
import { EnSentryTracingName, SentryTracingModule } from '@comfortable-typescript/nestjs-sentry';
@Module({
imports: [
// register input: HTTP_INTERNAL | DATABASE | REDIS | KAFKA | CUSTOM
SentryTracingModule.register(EnSentryOperationName.INTERNAL_HTTP),
]
})
export class SomeModule {}
- Start and finish wherever you want.
import { request } from 'undici';
import { SentryTracingService } from '@comfortable-typescript/nestjs-sentry';
export class SomService {
import
@Inject(SentryTracingService) private readonly sentryTracingService: SentryTracingSerice;
public async test() {
// startTracing optional input: HTTP_INTERNAL | DATABASE | REDIS | KAFKA | CUSTOM
const span = this.sentryTracingService.startTracing();
// http request through modules such as undici, axios
const response = await request('http://localhost:3000/test');
span.finishTracing();
return response;
}
}