@comfortable-typescript/nestjs-sentry
TypeScript icon, indicating that this package has built-in type declarations

0.0.33 • Public • Published

@comfortable-typescript/nestjs-sentry

Introduction

Sentry module for NestJS.

This module allows to use the following features of the sentry.

  1. Error issues reporting
  2. Performance
  3. 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

  1. 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 {}
  1. 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;
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @comfortable-typescript/nestjs-sentry

Weekly Downloads

988

Version

0.0.33

License

MIT

Unpacked Size

193 kB

Total Files

34

Last publish

Collaborators

  • obtamanyikibwa