koa-datadog-middleware is a Koa.js middleware designed for automatically reporting application performance metrics to Datadog via DogStatsD. It specifically tracks response times and request counts, categorizing them by HTTP status code, request path, and HTTP method. The middleware allows for the inclusion of custom tags, either through its initial configuration or dynamically by setting properties on `ctx.state.datadog` for individual requests. It leverages the `hot-shots` library internally for StatsD client functionality but critically overrides some default `hot-shots` configurations. The current stable version, 1.2.1, indicates a mature library focused on a specific integration, with a release cadence that suggests stability over frequent breaking changes. It differentiates itself by providing a ready-to-use Koa integration specifically for Datadog histograms without extensive boilerplate, making it straightforward to add basic observability to Koa applications.
npm install koa-datadog-middlewareVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic Koa application setup with `koa-datadog-middleware`, including configuration using environment variables, adding custom per-request tags, and basic error handling.
If dynamic DNS resolution or frequent host changes are required, explicitly set `cacheDns: false` in the middleware configuration.
If immediate metric transmission is critical and buffering is undesirable, explicitly set `maxBufferSize: 0` in the middleware configuration. Conversely, adjust `bufferFlushInterval` and `maxBufferSize` for optimal performance in high-throughput scenarios.
Ensure you have `const Koa = require('koa');` and `const app = new Koa();` at the beginning of your file before attempting to use `app.use()`.Verify the `host` and `port` settings in your `ddog` middleware configuration match your Datadog agent's `dogstatsd_stats_port` and host. Check if the Datadog agent is running and accessible from your application's host. Ensure no firewall rules block UDP on the specified port (default 8125).
Ensure you have `const ddog = require('koa-datadog-middleware');` at the top of your file. If using ES modules in an environment that supports it, try `import ddog from 'koa-datadog-middleware';` after verifying your setup.No dependency data recorded yet.