Skip to content

Commit c5c148a

Browse files
authored
Use the same tags across connect-datadog and hot-shots (github#24741)
* use the same tags across connect-datadog and hot-shots
1 parent 86b0cf5 commit c5c148a

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/statsd.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import StatsD from 'hot-shots'
22

3-
const mock = Boolean(process.env.NODE_ENV === 'test' || !process.env.DD_API_KEY)
3+
const { HEROKU_APP_NAME, NODE_ENV, DD_API_KEY } = process.env
4+
const mock = Boolean(NODE_ENV === 'test' || !DD_API_KEY)
45

6+
export const tags = ['app:docs', HEROKU_APP_NAME ? `heroku_app:${HEROKU_APP_NAME}` : false].filter(
7+
Boolean
8+
)
59
/**
610
* @type {import('hot-shots').StatsD}
711
*/
812
export default new StatsD({
913
prefix: 'docs.',
1014
mock,
11-
globalTags: {
12-
app: 'docs',
13-
heroku_app: process.env.HEROKU_APP_NAME,
14-
},
15+
globalTags: tags,
1516
})

middleware/connect-datadog.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import connectDatadog from 'connect-datadog'
2-
import statsd from '../lib/statsd.js'
2+
import statsd, { tags } from '../lib/statsd.js'
33

44
export default (req, res, next) => {
5-
const tags = []
6-
7-
if ('nextjs' in req.query) {
8-
tags.push('nextjs')
9-
}
10-
115
return connectDatadog({
126
dogstatsd: statsd,
137
method: true, // Track HTTP methods (GET, POST, etc)

0 commit comments

Comments
 (0)