Skip to content

Commit

Permalink
Updated to ignore /health and /metrics logs outs
Browse files Browse the repository at this point in the history
  • Loading branch information
Phara0h committed May 5, 2021
1 parent 1bd9eae commit 987ed08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ if (
is_testing = true;
}

const ignored_routes = [`/${config.serviceName}/metrics`, `/${config.serviceName}/health`];

if (config.log.logger) {
if (typeof config.log.logger === 'string') {
if (config.log.logger == 'wog') {
Expand Down Expand Up @@ -49,6 +51,10 @@ if (config.log.logger) {
req: function (req) {
var traceId = '';

if (ignored_routes.indexOf(req.url) > -1) {
return null;
}

if (config.tracing.enable) {
if (!req.span || req.span == '') {
if (is_testing) {
Expand Down Expand Up @@ -79,6 +85,9 @@ if (config.log.logger) {
},

res: function (reply) {
if (ignored_routes.indexOf(reply.request.url) > -1) {
return null;
}
return {
wog_type: 'reply',
statusCode: reply.statusCode,
Expand Down Expand Up @@ -211,7 +220,7 @@ app.get('/' + config.serviceName + '/metrics', (req, res) => {
});
app.get('/' + config.serviceName + '/health', (req, res) => res.code(200).send('All Systems Nominal'));
app.register(nstats.fastify(), {
ignored_routes: ['/' + config.serviceName + '/metrics', '/' + config.serviceName + '/health']
ignored_routes
});

if (config.portal.enable) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"http-proxy": "^1.17.0",
"ioredis": "^4.14.1",
"nodemailer": "^6.3.0",
"nstats": "^4.1.2",
"wog": "^4.0.3"
"nstats": "latest",
"wog": "latest"
},
"devDependencies": {
"@abeai/recho": "^1.4.0",
Expand Down

0 comments on commit 987ed08

Please sign in to comment.