Skip to content

SocketSomeone/nestjs-hot-shots

Repository files navigation

NestJS Hot-shots npm LICENSE Downloads Last Commit

Nest.JS logo

Hot-shots Module for Nest.js Framework. A Node.js client for Etsy's StatsD server, Datadog's DogStatsD server, and InfluxDB's Telegraf StatsD server.

Features

  • TypeScript types
  • Telegraf support
  • Events
  • Child clients
  • TCP/UDS Protocol support
  • Raw Stream Protocol support
  • Mock mode
  • Much more, including many bug fixes

For questions and support please use the Issues.

Installation

$ npm i nestjs-hot-shots hot-shots
$ yarn add nestjs-hot-shots hot-shots
$ pnpm add nestjs-hot-shots hot-shots

Usage

Once the installation process is complete, we can import the HotShotsModule into the root AppModule:

import { Module } from '@nestjs/common'
import { HotShotsModule } from 'nestjs-hot-shots';

@Module({
    imports: [
        HotShotsModule.forRoot({
            port: 8020,
            globalTags: { env: process.env.NODE_ENV }
        })
    ]
})
export class AppModule {
}

Then inject StatsD provider for use hot-shots:

import { Injectable } from '@nestjs/common';
import { StatsD } from 'hot-shots';

@Injectable()
export class AppMetrics {
    public constructor(private readonly metrics: StatsD) {
    }

    public metricStuff() {
        this.metrics.increment('somecounter');
    }
}

See the hot-shots module for more details.

Stay in touch

License

MIT © Alexey Filippov