{"library":"node-statsd","title":"Node.js StatsD Client (Legacy)","description":"This entry describes `node-statsd`, a client library for sending metrics to a StatsD server from Node.js applications. The specific version provided, 0.1.1, is exceptionally old, predating the 1.0.0 release. The package allows sending common StatsD metric types such as timings, increments, decrements, histograms, and gauges over UDP. It offers basic configuration for host, port, prefix, suffix, and optional global tags. Due to its age (last significant update over 7 years ago, with the provided version being even older), this client is considered largely abandoned. Modern Node.js applications should consider more actively maintained alternatives like `hot-shots` or `statsd-client` which offer broader compatibility, better error handling, and more features. The release cadence for this specific package is effectively non-existent.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install node-statsd"],"cli":null},"imports":["import { StatsD } from 'node-statsd';","const StatsD = require('node-statsd');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const StatsD = require('node-statsd');\nconst client = new StatsD({\n  host: process.env.STATSD_HOST ?? 'localhost',\n  port: parseInt(process.env.STATSD_PORT ?? '8125', 10),\n  prefix: 'my_app.',\n  global_tags: ['env:development', 'service:backend']\n});\n\n// Timing: records the duration of an event in milliseconds\nclient.timing('api_response_time', 150.7, 0.5, ['endpoint:users', 'method:GET']);\n\n// Increment: increments a counter by a value (default is 1)\nclient.increment('user_logins');\nclient.increment('failed_attempts', 5);\n\n// Decrement: decrements a counter by a value (default is -1)\nclient.decrement('active_sessions');\n\n// Gauge: sets a metric to an absolute value\nclient.gauge('current_memory_usage', process.memoryUsage().heapUsed / 1024 / 1024);\n\n// Histogram: sends data for histogram stat\nclient.histogram('request_duration_ms', 250, 0.1);\n\n// Set: counts unique occurrences of a stat\nclient.set('unique_visitors', 'user-abc-123');\n\n// Error handling for the underlying socket\nclient.socket.on('error', (error) => {\n  console.error('StatsD socket error:', error);\n});\n\nconsole.log('Metrics sent to StatsD (or attempted, check server logs).');","lang":"javascript","description":"Demonstrates initializing the StatsD client with optional parameters and sending various metric types like timing, increment, gauge, histogram, and set, including basic socket error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}