{"id":17546,"library":"connect-datadog","title":"Datadog Middleware for Express/Connect","description":"The `connect-datadog` package, currently at version 0.0.9 and last updated over seven years ago, provides a basic middleware for Express.js and Connect-compatible Node.js applications to send HTTP request metrics to a local Datadog Agent via the DogStatsD protocol. This middleware captures essential request telemetry such as response times, HTTP status codes, and request paths, allowing for rudimentary monitoring within Datadog dashboards. However, this library is officially deprecated and its GitHub repository is auto-archived due to inactivity. Datadog strongly recommends migrating to its comprehensive Application Performance Monitoring (APM) solutions, which offer advanced features, continuous updates, and broader integration capabilities for modern Node.js environments. There is no active release cadence for `connect-datadog`, marking it as an unmaintained and historical tool, superseded by Datadog's more robust and actively developed APM offerings. It uses `node-dogstatsd` internally, which itself has more modern alternatives.","status":"deprecated","version":"0.0.9","language":"javascript","source_language":"en","source_url":"git://github.com/DataDog/node-connect-datadog","tags":["javascript","datadog","middleware"],"install":[{"cmd":"npm install connect-datadog","lang":"bash","label":"npm"},{"cmd":"yarn add connect-datadog","lang":"bash","label":"yarn"},{"cmd":"pnpm add connect-datadog","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Internal client for sending metrics to DogStatsD agent. It is a direct dependency used by the middleware.","package":"node-dogstatsd","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not support ES module imports. The `require` call itself returns the middleware function.","wrong":"import connectDatadog from 'connect-datadog'; // ESM not supported","symbol":"connectDatadog","correct":"const connectDatadog = require('connect-datadog');\napp.use(connectDatadog({}));"},{"note":"Configuration is passed as an object to the middleware function. There are no exposed types for TypeScript users, nor are there named exports.","wrong":"import { DatadogOptions } from 'connect-datadog'; // No types, no named exports","symbol":"DatadogOptions","correct":"const connectDatadog = require('connect-datadog');\nconst ddOptions = {\n  stat: 'web.requests',\n  tags: ['env:production'],\n  response_code: true\n};\napp.use(connectDatadog(ddOptions));"},{"note":"The `dogstatsd` option expects an instance of a `node-dogstatsd` compatible client. Using a different StatsD client might lead to unexpected behavior or errors.","wrong":"const customDogstatsdClient = new SomeOtherClient(); // Must be node-dogstatsd compatible","symbol":"StatsDClientOverride","correct":"const connectDatadog = require('connect-datadog');\nconst StatsD = require('node-dogstatsd').StatsD;\nconst customDogstatsdClient = new StatsD({ host: '127.0.0.1', port: 8125 });\napp.use(connectDatadog({ dogstatsd: customDogstatsdClient }));"}],"quickstart":{"code":"const express = require('express');\nconst connectDatadog = require('connect-datadog');\nconst app = express();\nconst port = process.env.PORT || 3000;\n\n// Datadog middleware options\nconst ddOptions = {\n  stat: 'node.express.router',\n  tags: ['app:my-old-express-app', 'environment:development'],\n  path: true, // Include path tag\n  method: true, // Include http method tag\n  response_code: true // Include http response code tag\n};\n\n// Add middleware immediately before your router, as per original instructions.\n// NOTE: The example `app.use(app.router)` is deprecated in modern Express.\n// Instead, place this middleware before your route definitions.\napp.use(connectDatadog(ddOptions));\n\napp.get('/', (req, res) => {\n  res.send('Hello from Datadog-monitored Express App!');\n});\n\napp.get('/data', (req, res) => {\n  res.json({ message: 'Some data' });\n});\n\napp.listen(port, () => {\n  console.log(`Server listening at http://localhost:${port}`);\n  console.log('Ensure Datadog Agent with DogStatsD is running on the host.');\n});","lang":"javascript","description":"Demonstrates integrating the `connect-datadog` middleware into a basic Express application to send HTTP request metrics to a Datadog Agent."},"warnings":[{"fix":"Migrate to Datadog's official APM client for Node.js (e.g., `dd-trace`) which provides automatic instrumentation and richer features. Refer to the Datadog APM documentation for Node.js.","message":"The `connect-datadog` library is officially deprecated and its GitHub repository is auto-archived. Datadog strongly recommends migrating to Datadog APM for Node.js for comprehensive monitoring, as this library will receive no further updates and may not be compatible with future Node.js or Express versions.","severity":"breaking","affected_versions":">=0.0.9"},{"fix":"It is strongly advised to use Datadog APM or a more actively maintained StatsD client for Node.js (like `hot-shots`) for new projects and consider migrating existing ones.","message":"This package has not been updated in over seven years (last published version 0.0.9). It may have compatibility issues with modern Node.js versions (e.g., Node.js 14+) and recent Express.js versions, potentially leading to unexpected behavior or runtime errors.","severity":"gotcha","affected_versions":"0.0.9"},{"fix":"Ensure the Datadog Agent is installed, running, and DogStatsD is enabled. Verify network connectivity between your application and the DogStatsD UDP port (default 8125). Refer to Datadog Agent and DogStatsD setup documentation.","message":"The middleware relies on a running Datadog Agent with DogStatsD enabled on the host machine or a reachable network address. If the agent is not running or misconfigured, metrics will not be collected by Datadog.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Remove the line `app.use(app.router);` from your application. In modern Express, routing is handled automatically and this line is unnecessary and can cause warnings or errors.","message":"The usage pattern `app.use(app.router);` shown in the original README is deprecated in modern Express.js versions. Routing middleware should typically be registered directly after global middleware, before defining specific routes.","severity":"deprecated","affected_versions":"0.0.9 (when used with Express 4.x+)"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"This package is CommonJS-only. To use it in an ESM project, you might need a wrapper or dynamic import, but it's strongly recommended to migrate to a modern, ESM-compatible Datadog APM client (e.g., `dd-trace`) instead.","cause":"Attempting to use `require()` in an ES module (ESM) context when `package.json` specifies `\"type\": \"module\"` or the file has a `.mjs` extension.","error":"ReferenceError: require is not defined"},{"fix":"Verify the Datadog Agent is installed and running on your host. Check the Agent's logs for DogStatsD errors. Confirm that UDP port 8125 (default) is open and reachable by your application. Ensure the `dogstatsd` client configured in `connect-datadog` points to the correct host and port if not using defaults.","cause":"The Datadog Agent with DogStatsD might not be running, or there's a network issue preventing the application from sending UDP packets to the agent.","error":"Metrics are not appearing in Datadog dashboards for my Express application."},{"fix":"Remove the line `app.use(app.router);` from your application. In modern Express, routing is handled automatically and this line is unnecessary and can cause warnings or errors.","cause":"The quickstart example `app.use(app.router);` is an outdated practice from older Express.js versions.","error":"TypeError: app.router is deprecated, you should probably just remove it."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}