1.0.9 • Published 2 years ago

datadog-decorators v1.0.9

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

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago