The nestjs-hot-shots package provides a dedicated module for integrating the `hot-shots` (StatsD client) library into NestJS applications. It simplifies sending metrics to StatsD, DogStatsD, or Telegraf servers. Currently stable at version 4.0.0 (released January 2026), it typically sees releases aligning with major NestJS versions or significant feature additions/bug fixes. Key differentiators include full TypeScript support, out-of-the-box integration for common NestJS patterns like dependency injection for the `StatsD` client, a dedicated `MetricsService` for creating various metric types (counters, gauges, histograms), and a convenient `HttpMetricsMiddleware` for automated HTTP request metric collection. This module abstracts much of the boilerplate associated with setting up and using a StatsD client in a NestJS project, offering a streamlined experience for metric reporting.
npm install nestjs-hot-shotsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to configure the `HotShotsModule` with environment variables, inject the underlying `StatsD` client, use the `MetricsService` for custom metrics, and apply `HttpMetricsMiddleware` for automated HTTP request tracking.
Update `hot-shots` to `^12.0.0` and your NestJS packages (`@nestjs/common`, `@nestjs/core`) to a compatible version (e.g., 10.x or 11.x) in your `package.json` and reinstall dependencies.
Review your `HotShotsModule.forRoot()` configuration. If you were using a `project` field for service naming, consider consolidating service-level tagging into `globalTags` or adjusting your metrics naming strategy.
Migrate your application to use direct `StatsD` injection (from `hot-shots`) or the provided `MetricsService` instead of any deprecated `StatsDService` or similar. Refer to the current usage examples.
Always run `npm install nestjs-hot-shots hot-shots` (or `yarn add` / `pnpm add`) to ensure both packages are present.
Run `npm install hot-shots` or `yarn add hot-shots`.
Ensure `HotShotsModule.forRoot(...)` is included in the `imports` array of your root or feature module, providing valid configuration options.
If you intend to use the higher-level metric creation methods, inject `MetricsService` from `nestjs-hot-shots`. The `StatsD` client provides direct `increment`, `gauge`, etc., methods.
Add the `configure` method to your `AppModule` with the correct signature: `public configure(consumer: MiddlewareConsumer) { ... }`.