Skip to content

Commit

Permalink
Use connectDatadog(e) (#16888)
Browse files Browse the repository at this point in the history
* npm i connect-datadog

* Add connectDatadog middleware

* Add comments

* Use DD_API_KEY to gate

Co-authored-by: Chiedo John <[email protected]>
  • Loading branch information
JasonEtco and chiedo authored Dec 11, 2020
1 parent 6a28bfc commit eaf2a67
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
8 changes: 8 additions & 0 deletions middleware/connect-datadog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const connectDatadog = require('connect-datadog')
const statsd = require('../lib/statsd')

module.exports = connectDatadog({
dogstatsd: statsd,
method: true, // Track HTTP methods (GET, POST, etc)
response_code: true // Track response codes
})
5 changes: 5 additions & 0 deletions middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ module.exports = function (app) {
app.use(require('morgan')('dev', { skip: (req, res) => !isDevelopment }))
if (isDevelopment) app.use(require('./webpack'))

// *** Observability ***
if (process.env.DD_API_KEY) {
app.use(require('./connect-datadog'))
}

// *** Early exits ***
// Don't use the proxy's IP, use the requester's for rate limiting
// See https://expressjs.com/en/guide/behind-proxies.html
Expand Down
30 changes: 24 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"cheerio": "^1.0.0-rc.3",
"clipboard": "^2.0.6",
"compression": "^1.7.4",
"connect-datadog": "0.0.9",
"connect-slashes": "^1.4.0",
"cookie-parser": "^1.4.5",
"copy-webpack-plugin": "^6.0.3",
Expand Down

0 comments on commit eaf2a67

Please sign in to comment.