Skip to content

Commit eaf2a67

Browse files
JasonEtcochiedo
andauthored
Use connectDatadog(e) (#16888)
* npm i connect-datadog * Add connectDatadog middleware * Add comments * Use DD_API_KEY to gate Co-authored-by: Chiedo John <2156688+chiedo@users.noreply.github.com>
1 parent 6a28bfc commit eaf2a67

4 files changed

Lines changed: 38 additions & 6 deletions

File tree

middleware/connect-datadog.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const connectDatadog = require('connect-datadog')
2+
const statsd = require('../lib/statsd')
3+
4+
module.exports = connectDatadog({
5+
dogstatsd: statsd,
6+
method: true, // Track HTTP methods (GET, POST, etc)
7+
response_code: true // Track response codes
8+
})

middleware/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ module.exports = function (app) {
1414
app.use(require('morgan')('dev', { skip: (req, res) => !isDevelopment }))
1515
if (isDevelopment) app.use(require('./webpack'))
1616

17+
// *** Observability ***
18+
if (process.env.DD_API_KEY) {
19+
app.use(require('./connect-datadog'))
20+
}
21+
1722
// *** Early exits ***
1823
// Don't use the proxy's IP, use the requester's for rate limiting
1924
// See https://expressjs.com/en/guide/behind-proxies.html

package-lock.json

Lines changed: 24 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"cheerio": "^1.0.0-rc.3",
3535
"clipboard": "^2.0.6",
3636
"compression": "^1.7.4",
37+
"connect-datadog": "0.0.9",
3738
"connect-slashes": "^1.4.0",
3839
"cookie-parser": "^1.4.5",
3940
"copy-webpack-plugin": "^6.0.3",

0 commit comments

Comments
 (0)