Skip to content

Commit

Permalink
Merge pull request #88 from thiagobustamante/master
Browse files Browse the repository at this point in the history
new stats request mapper
  • Loading branch information
thiagobustamante committed Dec 20, 2017
2 parents d6b3de2 + 83681f7 commit 1a73157
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/stats/request-mappers/operation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

import * as express from 'express';
import { normalizePath } from '../../utils/path';

module.exports = function(config: any) {
return (req: express.Request): string => {
return `${req.method} - ${normalizePath(req.path)}`;
};
};
4 changes: 3 additions & 1 deletion src/utils/middleware-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export class MiddlewareLoader {
'consul': '../servicediscovery/middleware/provider/consul'
},
'stats/request/mapper': {
'path': '../stats/request-mappers/path'
'operation': '../stats/request-mappers/operation',
'path': '../stats/request-mappers/path',
'total': '../stats/request-mappers/total'
}
};

Expand Down
11 changes: 10 additions & 1 deletion test/data/apis/limitedApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
"target": {
"host": "http://httpbin.org"
},
"timeout": 5000
"timeout": 5000,
"statsConfig": {
"requestMapper": {
"id": "operation"
},
"granularity": {
"duration": "1 hour",
"ttl": "2 days"
}
}
},
"throttling": [
{
Expand Down

0 comments on commit 1a73157

Please sign in to comment.