@comfortable-typescript/nestjs-sentry
v0.1.10
Published
Sentry module for NestJS
Downloads
1,320
Readme
@comfortable-typescript/nestjs-sentry
Introduction
This module allows to use the following features of the sentry.
- Error issues reporting
- Performance
- Profiling
Installation
npm install --save-dev @comfortable-typescript/nestjs-sentry
Usage
Include SentryModule
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 {}
Tracing
- 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;
}
}