1.0.9 • Published 9 months ago

datadog-decorators v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months 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

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago