npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nestjs-hot-shots

v4.0.0

Published

Hot-shots Module for Nest.js Framework

Readme

NestJS Hot-shots npm LICENSE Downloads Last Commit

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');
    }
}

Metrics

You can use the MetricsService for metrics collection. It`s factory for creating metrics. It provides a set of methods to create different types of metrics, such as counters, gauges, and histograms.

import { Controller, Post } from '@nestjs/common';
import { MetricsService } from 'nestjs-hot-shots';
import { StatsD } from 'hot-shots';

@Controller
export class BooksController {
    private readonly booksAdded = this.metricsService.getCounter('books.added.count');

    public constructor(private readonly metricsService: MetricsService) {
    }

    @Post()
    public async addBook() {
        // some logic
        this.booksAdded.add();
    }
}

| Method | Description | |----------------------------------|--------------------------------------------------------| | getCounter(name: string) | Returns a counter metric with the given name. | | getGauge(name: string) | Returns a gauge metric with the given name. | | getHistogram(name: string) | Returns a histogram metric with the given name. | | getTimer(name: string) | Returns a timer metric with the given name. | | getUpDownCounter(name: string) | Returns an up-down counter metric with the given name. |

HTTP Metrics via Middleware

You can use the HttpMetricsMiddleware to collect HTTP metrics. It will automatically collect metrics for all incoming requests and outgoing responses.

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

@Module({
    imports: [
        HotShotsModule.forRoot({
            ...
        })
    ]
})
export class AppModule {
    public configure(consumer: MiddlewareConsumer) {
        consumer
            .apply(HttpMetricsMiddleware)
            .forRoutes('*');
    }
}

| Metric | Description | Type | |--------------------------------------|-------------------------------------------------|-----------| | http_server_request_count | Total number of requests received by the server | Counter | | http_server_response_count | Total number of responses sent by the server | Counter | | http_server_duration | Total time taken to process requests | Histogram | | http_server_request_size | Size of incoming bytes. | Histogram | | http_server_response_size | Size of outgoing bytes. | Histogram | | http_server_response_success_count | Total number of all successful responses. | Counter | | http_server_response_error_count | Total number of server error responses. | Counter | | http_client_request_error_count | Total number of client error requests. | Counter | | http_server_abort_count | Total number of aborted requests | Counter |

Inspired by nestjs-otel

See the hot-shots module for more details.

Stay in touch

License

MIT © Alexey Filippov