Skip to content

Commit

Permalink
feat: Added hostname to node request info. (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
RicardoNeves authored Sep 20, 2022
1 parent b2759c5 commit b616628
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const metrics = {any_metric: 'any_metric_result'};

beforeAll(() => {
advanceTo(new Date(2019, 1, 1, 0, 0, 0));
process.env.HOSTNAME = 'dummy-hostname-id';
});

beforeEach(() => {
Expand All @@ -28,6 +29,7 @@ afterEach(() => {

afterAll(() => {
clear();
process.env.HOSTNAME = undefined;
});

describe('formatNodeRequest custom format', () => {
Expand Down Expand Up @@ -81,6 +83,7 @@ describe('formatNodeRequest custom format', () => {
context: {
any_context: 'any_context_result',
},
debugContainerHostname: 'dummy-hostname-id',
http: {
method: 'GET',
referer: '/referer',
Expand All @@ -107,6 +110,7 @@ describe('formatNodeRequest custom format', () => {
context: {
any_context: 'any_context_result',
},
debugContainerHostname: 'dummy-hostname-id',
}));
});

Expand All @@ -127,6 +131,7 @@ describe('formatNodeRequest custom format', () => {
context: {
any_context: 'any_context_result',
},
debugContainerHostname: 'dummy-hostname-id',
}));
});

Expand All @@ -138,6 +143,7 @@ describe('formatNodeRequest custom format', () => {
level: false,
datetime: '2019-02-01T00:00:00.000Z',
channel: 'app',
debugContainerHostname: 'dummy-hostname-id',
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const formatNodeRequest = ({
channel,
metrics,
context,
debugContainerHostname: process.env.HOSTNAME,
};

// Add http object when req or res have entries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
"type": "string",
"format": "date-time",
"examples": [ "2019-05-02T06:59:01.345464+00:00" ]
},
},

"debugContainerHostname": {
"description": "The value used by the HOSTNAME env var",
"type": "string"
},

"extra": {
"description": "Extra data to be passed which is not implicitly within the context of the log. This can be unstructured data.",
Expand Down
2 changes: 1 addition & 1 deletion packages/kununu-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kununu/kununu-utils",
"version": "2.2.2",
"version": "2.2.3",
"description": "Utility functions used within kununu client applications",
"main": "dist",
"devDependencies": {
Expand Down

0 comments on commit b616628

Please sign in to comment.