File size: 515 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// @flow
import statsdMiddleware from 'express-hot-shots';
import { statsd } from '../statsd';

const middleware = statsdMiddleware({
  client: statsd,
});

export default (
  req: express$Request,
  res: express$Response,
  next: express$NextFunction
) => {
  // Set a sensible default req.statsdKey, which is what will be shown in the DataDog UI. Example key:
  // hyperion.http.get
  // $FlowFixMe
  req.statsdKey = `http.${req.method.toLowerCase() || 'unknown_method'}`;
  return middleware(req, res, next);
};