1.0.9 • Published 3 years ago

datadog-decorators v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NestJS Datadog Custom Decorator

Install

npm install

npm i --save datadog-decorators

yarn install

yarn add datadog-decorators

How To Use

Import at the controller file, apply it to the Controller class:

import { RequestRate } from 'datadog-decorators';

@Controller('test')
@RequestRate()
export class TestController {
  ...
}

or apply it to method:

import { RequestRate } from 'datadog-decorators';

@Controller('test')
export class TestController {
  
  @Post('')
  @RequestRate()
  async create(@Body() body) {
    ...
  }
}

You can add tags in key-value object to decorator like this:

import { RequestRate } from 'datadog-decorators';

@Controller('test')
export class TestController {
  
  @Post('')
  @RequestRate({ id: 1, content: 'test' })
  async create(@Body() body) {
    ...
  }
}

NOTE: The default metric prefix is 'my_collector'. To change this, you can set the environment variable DD_METRIC_PREFIX in your .env file

Available decorators

DecoratorsNoteDatadog Metric Name
ApiUsagemeasure total number of api callsapi_usage
ErrorRatemeasure error rate and success rate in totalerror_rate
RequestVolumemeasure total of requestsrequest_volume
ResponseTimemeasure API's response timeresponse_time
1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago