Skip to content

Commit

Permalink
Add prefix to inbound header logs (#97)
Browse files Browse the repository at this point in the history
- Updated the mapInRes function in transformers.js to include headers in metaHeaders
- Adjusted tests in requestProxyTest.js to reflect the changes in transformers.js
- This change will help in better log management by differentiating inbound headers
  • Loading branch information
nikostoulas authored Oct 5, 2023
1 parent 0694f0e commit ff58b49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
3 changes: 1 addition & 2 deletions lib/transformers/transformers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ const mapInRes = (res, req, startedAt, reqId, opts) => {
contentLength,
userAgent,
log_tag: logTags.CATEGORY.INBOUND_RESPONSE.TAG,
metaHeaders: { request: req.metaHeaders },
headers
metaHeaders: { request: req.metaHeaders, ...headers }
};
};

Expand Down
12 changes: 4 additions & 8 deletions test/lib/adapters/default/requestProxyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ describe('#defaultAdapter', () => {
opts: {
request: {
enabled: true
}
},
headersRegex: new RegExp('^X-.*', 'i')
}
});
const options = {
Expand Down Expand Up @@ -59,7 +60,7 @@ describe('#defaultAdapter', () => {
const httpRequest = () => {
return {
on: (on, cb) => {
const res = {};
const res = { headers: { 'x-foo': 'foo' } };
cb(res);
logger.info.callCount.should.equal(2);
logger.info.args[0][0].should.eql({
Expand Down Expand Up @@ -89,8 +90,7 @@ describe('#defaultAdapter', () => {
contentLength: 0,
userAgent: '',
log_tag: 'inbound_response',
headers: {},
metaHeaders: { request: {} }
metaHeaders: { request: {}, headers: { 'x-foo': 'foo' } }
});
}
};
Expand Down Expand Up @@ -276,7 +276,6 @@ describe('#defaultAdapter', () => {
contentLength: 0,
userAgent: '',
log_tag: 'inbound_response',
headers: {},
metaHeaders: { request: {} }
});
});
Expand Down Expand Up @@ -417,7 +416,6 @@ describe('#defaultAdapter', () => {
contentLength: 0,
userAgent: '',
log_tag: 'inbound_response',
headers: {},
metaHeaders: { request: {} }
});
});
Expand Down Expand Up @@ -491,7 +489,6 @@ describe('#defaultAdapter', () => {
contentLength: 0,
userAgent: '',
log_tag: 'inbound_response',
headers: {},
metaHeaders: {
request: {}
}
Expand Down Expand Up @@ -718,7 +715,6 @@ describe('#defaultAdapter', () => {
contentLength: 0,
userAgent: '',
log_tag: 'inbound_response',
headers: {},
metaHeaders: {
request: {}
}
Expand Down

0 comments on commit ff58b49

Please sign in to comment.