@strongnguyen/nestjs-apm
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

nestjs-elastic-apm

Installation

$ npm i @strongnguyen/nestjs-apm

Use

app.module.ts

import { ApmModule } from '@strongnguyen/nestjs-apm';

@Module({
    imports: [
        ApmModule.registerAsync(
            imports: [ConfigModule],
            useFactory: (configService: ConfigService) => ({
                active: configService.get('APM_ACTIVATE'),
                serviceName: configService.get('APM_SERVICE_NAME'),
                serverUrl: configService.get('APM_SERVER_URL'),
                secretToken: configService.get('APM_SECRET_TOKEN'),
                environment: configService.get('APM_ENV'),
                disableInstrumentations: 
                  configService.get('APM_DISABLE_INSTRUMENTATIONS').split(','), // optional
            }),
            inject: [ConfigService],
        )
    ]
})
export class AppModule {}

Usage in the service

...
import { ApmService } from '@strongnguyen/nestjs-apm';
...
...
@Injectable()
export class TestService {
constructor(private readonly apmService: ApmService) {}

doSomething(): void {
const span = this.apmService.startSpan('Custom span name');
....
span.end();
}
}
...

Env variables

# Override service name from package.json
APM_SERVICE_NAME
# APM Server requires a token
APM_SECRET_TOKEN
# APM Server URL
APM_SERVER_URL
# Set 'true' value to enable APM agent
APM_ACTIVATE
# Environment run app local / production / develop
APM_ENV
# Set comma-separated values to disable particular modules to be instrumented
APM_DISABLE_INSTRUMENTATIONS

Readme

Keywords

Package Sidebar

Install

npm i @strongnguyen/nestjs-apm

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

16.1 kB

Total Files

23

Last publish

Collaborators

  • strongnguyen