{"id":14733,"library":"node-dogstatsd","title":"Node.js Datadog StatsD Client","description":"node-dogstatsd is an unmaintained Node.js client specifically designed for Datadog's extended StatsD server, differentiating itself from generic StatsD clients by supporting Datadog-specific features like histograms and tags. The package's current stable version is 0.0.7, indicating a very old codebase. It was initially an extension of Steve Ivy's `node-statsd`, adding Datadog's proprietary features. Given its version number and engine requirements (Node.js >=0.1.97), it is largely incompatible with modern Node.js environments and ecosystems. There is no active release cadence, and the project appears to be abandoned, making it unsuitable for new development. Its core utility lies in providing an API to send metrics, timings, and custom events with tags and histograms to a Datadog agent.","status":"abandoned","version":"0.0.7","language":"javascript","source_language":"en","source_url":"git://github.com/joybro/node-dogstatsd","tags":["javascript"],"install":[{"cmd":"npm install node-dogstatsd","lang":"bash","label":"npm"},{"cmd":"yarn add node-dogstatsd","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-dogstatsd","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package exclusively uses CommonJS `require` syntax. The `StatsD` class is a named export from the main module.","wrong":"import { StatsD } from 'node-dogstatsd';","symbol":"StatsD","correct":"const StatsD = require('node-dogstatsd').StatsD;"}],"quickstart":{"code":"const StatsD = require('node-dogstatsd').StatsD;\n\n// Initialize the client with your Datadog agent host and port\n// Replace '127.0.0.1' with your Datadog agent's IP or hostname\n// Standard StatsD port is 8125\nconst c = new StatsD('127.0.0.1', 8125);\n\n// Basic increment and decrement operations\nc.increment('node_test.requests_total');\nc.incrementBy('node_test.requests_total', 5);\nc.decrement('node_test.active_users');\n\n// Record a timing metric (e.g., latency in milliseconds)\nc.timing('node_test.api_response_time', 250); // 250 ms\n\n// Record a histogram metric (Datadog-specific)\n// Useful for percentile aggregation\nc.histogram('node_test.data_processing_size', 1024); // Size in bytes\n\n// Increment a metric with a specific tag (Datadog-specific)\nc.increment('node_test.event_count', 1, ['environment:production', 'feature:login']);\n\n// Listen for socket errors (recommended for robustness)\nc.socket.on('error', function (exception) {\n   console.error(\"Error event in socket.send(): \" + exception.message);\n   // Implement proper error handling here, e.g., logging to a file or an error tracking service\n});\n\nconsole.log(\"Datadog metrics sent successfully (check your Datadog agent logs for verification).\");\n// In a real application, metrics would typically be sent throughout the application's lifecycle.","lang":"javascript","description":"This quickstart demonstrates how to initialize the `node-dogstatsd` client and send various metric types including increments, timings, histograms, and tagged metrics to a Datadog agent, along with basic socket error handling."},"warnings":[{"fix":"Do not use this package for new projects. Consider actively maintained alternatives like `@datadog/dogstatsd` or `dd-trace` for modern Node.js applications.","message":"This package specifies `engines: {\"node\": \">=0.1.97\"}`, making it incompatible with modern Node.js versions. Attempting to install or run it on recent Node.js environments will likely result in errors or undefined behavior.","severity":"breaking","affected_versions":">=0.0.7"},{"fix":"Ensure you are using a Datadog agent that supports the extended StatsD protocol when utilizing histograms and tags. For generic StatsD, use a standard StatsD client.","message":"The `histogram` and `tags` features provided by this client are specific to Datadog's extended StatsD implementation. These features will not function correctly with generic StatsD servers and may lead to data loss or silent failures if used outside a Datadog ecosystem.","severity":"gotcha","affected_versions":">=0.0.7"},{"fix":"This package should be considered a legacy dependency. Migrate to a modern and actively maintained Datadog client library as soon as possible.","message":"The package is severely outdated (version 0.0.7, last updated around Node.js 0.1 era) and appears to be unmaintained. This poses significant security risks, lacks support for modern features, and will not receive critical bug fixes.","severity":"breaking","affected_versions":">=0.0.7"},{"fix":"Implement robust socket error handling using `c.socket.on('error', function(exception){ ... });` and monitor for unexpected application crashes related to metric submission.","message":"The README explicitly states \"Error handling policy: TODO\" regarding documenting exceptions, implying that the library's error handling might be incomplete or poorly defined, potentially leading to unhandled exceptions that could crash the application.","severity":"gotcha","affected_versions":">=0.0.7"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Correct the import statement to `const StatsD = require('node-dogstatsd').StatsD;`","cause":"The package's main export is an object, and the `StatsD` class is a property of that object. Attempting to `require('node-dogstatsd')` without accessing `.StatsD` will result in this error.","error":"TypeError: Cannot read properties of undefined (reading 'StatsD')"},{"fix":"Verify that the Datadog agent is running and accessible at the specified `host` and `port`. Check network connectivity and firewall rules. Implement `c.socket.on('error', ...)` to catch and handle these exceptions gracefully.","cause":"This error typically indicates an issue with the underlying UDP socket, such as the Datadog agent not running, incorrect host/port configuration, or network connectivity problems preventing the client from sending data.","error":"Error: send EPIPE"},{"fix":"This warning signifies severe version incompatibility. It is highly recommended to abandon this package and migrate to a modern Datadog client library that supports your current Node.js version.","cause":"The package specifies an extremely old Node.js version requirement, which is incompatible with modern Node.js installations, leading to npm warnings or installation failures.","error":"npm WARN node-dogstatsd@0.0.7 requires a peer of node@>=0.1.97 but none is installed."}],"ecosystem":"npm"}