Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/adapters/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ function extractLogCtx(ctx) {
}

function onInboundRequest({ ctx }) {
if (this.inbound.blacklistedPaths?.includes(ctx.request?.path)) {
return;
}

extractLogCtx.call(this, ctx);

const {
Expand All @@ -129,6 +133,10 @@ function onInboundRequest({ ctx }) {
}

function onOutboundResponse({ ctx }) {
if (this.inbound.blacklistedPaths?.includes(ctx.request?.path)) {
return;
}

if (!ctx.logCtx) {
extractLogCtx.call(this, ctx);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module.exports = (options = {}) => {
},
level: 'info',
includeHost: false,
maxBodyValueChars: undefined
maxBodyValueChars: undefined,
blacklistedPaths: undefined
},
outbound: {
enabled: true,
Expand Down
31 changes: 31 additions & 0 deletions test/lib/adapters/default/onOutboundResponseTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,36 @@ describe('#defaultAdapter', () => {
duration: NaN
});
});
it('should respect inbound blacklisted paths', () => {
const ctx = {
state: {},
request: {
method: 'GET',
headers: {
test_user_id_header: 'test-user-id'
},
path: '/health',
req: {
url: '/health'
}
},
req: {
headers: {
'x-ap-id': uuid
}
},
originalUrl: '/health',
response: {
status: 200
}
};
const opts = getOpts(sandbox);
opts.inbound.blacklistedPaths = ['/health'];

defaultAdapter.onInboundRequest.call(opts, { ctx });
defaultAdapter.onOutboundResponse.call(opts, { ctx });
opts.logger.info.args.should.be.empty();
opts.logger.info.called.should.be.false();
});
});
});
3 changes: 2 additions & 1 deletion types/riviere.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export function riviere(options?: {
enabled: boolean
},
level: string,
maxBodyValueChars?: number
maxBodyValueChars?: number,
blacklistedPaths?: string[]
},
outbound?: {
enabled: boolean,
Expand Down
Loading