Skip to content

Commit 4c24724

Browse files
authored
Remove type and platform from logs (#15109)
We're not using them for anything, and we're trying to reduce noise in the logs by removing fields we don't need. In addition, these fields duplicate information that's already in the path, which is also logged. For example, a request to `/AppsArticle` would have "apps" as the platform and "article" as the type. Furthermore, an extra function call is needed to log them whenever a new handler is created, whereas the path is logged automatically for every request. This may be why they're currently logged inconsistently, with both "app" and "apps" being used, and the platform sometimes not included, although some of this could also be solved by changing the types on `recordTypeAndPlatform`.
1 parent 25ab535 commit 4c24724

File tree

9 files changed

+3
-50
lines changed

9 files changed

+3
-50
lines changed

dotcom-rendering/src/server/handler.allEditorialNewslettersPage.web.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import type { RequestHandler } from 'express';
22
import { enhanceNewslettersPage } from '../model/enhance-newsletters-page';
33
import { validateAsAllEditorialNewslettersPageType } from '../model/validate';
44
import { makePrefetchHeader } from './lib/header';
5-
import { recordTypeAndPlatform } from './lib/logging-store';
65
import { renderEditorialNewslettersPage } from './render.allEditorialNewslettersPage.web';
76

87
export const handleAllEditorialNewslettersPage: RequestHandler = (
98
{ body },
109
res,
1110
) => {
12-
recordTypeAndPlatform('newsletters');
1311
const feNewslettersData = validateAsAllEditorialNewslettersPageType(body);
1412
const newslettersPage = enhanceNewslettersPage(feNewslettersData);
1513
const { html, prefetchScripts } = renderEditorialNewslettersPage({

dotcom-rendering/src/server/handler.article.apps.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import { validateAsBlock, validateAsFEArticle } from '../model/validate';
55
import { enhanceArticleType } from '../types/article';
66
import type { FEBlocksRequest } from '../types/frontend';
77
import { makePrefetchHeader } from './lib/header';
8-
import { recordTypeAndPlatform } from './lib/logging-store';
98
import { renderAppsBlocks, renderArticle } from './render.article.apps';
109

1110
export const handleAppsArticle: RequestHandler = ({ body }, res) => {
12-
recordTypeAndPlatform('article', 'apps');
13-
1411
const frontendData = validateAsFEArticle(body);
1512
const article = enhanceArticleType(frontendData, 'Apps');
1613
const { html, prefetchScripts } = renderArticle(article);
@@ -20,8 +17,6 @@ export const handleAppsArticle: RequestHandler = ({ body }, res) => {
2017
};
2118

2219
export const handleAppsInteractive: RequestHandler = ({ body }, res) => {
23-
recordTypeAndPlatform('interactive', 'app');
24-
2520
const frontendData = validateAsFEArticle(body);
2621
const article = enhanceArticleType(frontendData, 'Apps');
2722
const { html, prefetchScripts } = renderArticle(article);
@@ -30,7 +25,6 @@ export const handleAppsInteractive: RequestHandler = ({ body }, res) => {
3025
};
3126

3227
export const handleAppsBlocks: RequestHandler = ({ body }, res) => {
33-
recordTypeAndPlatform('blocks', 'app');
3428
const {
3529
blocks,
3630
format,

dotcom-rendering/src/server/handler.article.web.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import { validateAsBlock, validateAsFEArticle } from '../model/validate';
55
import { enhanceArticleType } from '../types/article';
66
import type { FEBlocksRequest } from '../types/frontend';
77
import { makePrefetchHeader } from './lib/header';
8-
import { recordTypeAndPlatform } from './lib/logging-store';
98
import { renderBlocks, renderHtml } from './render.article.web';
109

1110
export const handleArticle: RequestHandler = ({ body }, res) => {
12-
recordTypeAndPlatform('article', 'web');
13-
1411
const frontendData = validateAsFEArticle(body);
1512
const article = enhanceArticleType(frontendData, 'Web');
1613
const { html, prefetchScripts } = renderHtml({
@@ -21,8 +18,6 @@ export const handleArticle: RequestHandler = ({ body }, res) => {
2118
};
2219

2320
export const handleInteractive: RequestHandler = ({ body }, res) => {
24-
recordTypeAndPlatform('interactive', 'web');
25-
2621
const frontendData = validateAsFEArticle(body);
2722
const article = enhanceArticleType(frontendData, 'Web');
2823
const { html, prefetchScripts } = renderHtml({
@@ -33,7 +28,6 @@ export const handleInteractive: RequestHandler = ({ body }, res) => {
3328
};
3429

3530
export const handleBlocks: RequestHandler = ({ body }, res) => {
36-
recordTypeAndPlatform('blocks');
3731
const {
3832
blocks,
3933
format,

dotcom-rendering/src/server/handler.front.web.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type { Front } from '../types/front';
1717
import type { FETagType } from '../types/tag';
1818
import type { TagPage } from '../types/tagPage';
1919
import { makePrefetchHeader } from './lib/header';
20-
import { recordTypeAndPlatform } from './lib/logging-store';
2120
import { renderFront, renderTagPage } from './render.front.web';
2221

2322
const enhanceFront = (body: unknown): Front => {
@@ -161,7 +160,6 @@ const enhanceTagPage = (body: unknown): TagPage => {
161160
};
162161

163162
export const handleFront: RequestHandler = ({ body }, res) => {
164-
recordTypeAndPlatform('front');
165163
const front = enhanceFront(body);
166164
const { html, prefetchScripts } = renderFront({
167165
front,
@@ -170,7 +168,6 @@ export const handleFront: RequestHandler = ({ body }, res) => {
170168
};
171169

172170
export const handleTagPage: RequestHandler = ({ body }, res) => {
173-
recordTypeAndPlatform('tagPage');
174171
const tagPage = enhanceTagPage(body);
175172
const { html, prefetchScripts } = renderTagPage({
176173
tagPage,

dotcom-rendering/src/server/handler.hostedContent.web.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ import type { RequestHandler } from 'express';
22
import { validateAsFEHostedContent } from '../model/validate';
33
import { enhanceHostedContentType } from '../types/hostedContent';
44
import { makePrefetchHeader } from './lib/header';
5-
import { recordTypeAndPlatform } from './lib/logging-store';
65
import { renderHtml } from './render.hostedContent.web';
76

87
export const handleHostedContent: RequestHandler = ({ body }, res) => {
9-
recordTypeAndPlatform('article', 'web');
10-
118
const frontendData = validateAsFEHostedContent(body);
129
const hostedContent = enhanceHostedContentType(frontendData);
1310
const { html, prefetchScripts } = renderHtml({

dotcom-rendering/src/server/handler.sportDataPage.web.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import type {
2828
Region,
2929
} from '../sportDataPage';
3030
import { makePrefetchHeader } from './lib/header';
31-
import { recordTypeAndPlatform } from './lib/logging-store';
3231
import { renderSportPage } from './render.sportDataPage.web';
3332

3433
const decideMatchListPageKind = (pageId: string): FootballMatchListPageKind => {
@@ -122,7 +121,6 @@ const parseFEFootballMatchList = (
122121
};
123122

124123
export const handleFootballMatchListPage: RequestHandler = ({ body }, res) => {
125-
recordTypeAndPlatform('footballMatchListPage', 'web');
126124
const footballDataValidated: FEFootballMatchListPage =
127125
validateAsFootballMatchListPage(body);
128126

@@ -161,7 +159,6 @@ const parseFEFootballTables = (
161159
};
162160

163161
export const handleFootballTablesPage: RequestHandler = ({ body }, res) => {
164-
recordTypeAndPlatform('FootballTablesPage', 'web');
165162
const footballTablesPageValidated: FEFootballTablesPage =
166163
validateAsFootballTablesPage(body);
167164

@@ -199,8 +196,6 @@ const parseFECricketMatch = (data: FECricketMatchPage): CricketMatchPage => {
199196
};
200197

201198
export const handleCricketMatchPage: RequestHandler = ({ body }, res) => {
202-
recordTypeAndPlatform('CricketMatchPage', 'web');
203-
204199
const cricketMatchPageValidated: FECricketMatchPage =
205200
validateAsCricketMatchPageType(body);
206201

@@ -241,8 +236,6 @@ const parseFEFootballMatch = (
241236
};
242237

243238
export const handleFootballMatchPage: RequestHandler = ({ body }, res) => {
244-
recordTypeAndPlatform('FootballMatchPage', 'web');
245-
246239
const footballMatchPageValidated: FEFootballMatchPage =
247240
validateAsFootballMatchPageType(body);
248241
const parsedFootballMatchData = parseFEFootballMatch(

dotcom-rendering/src/server/lib/logging-middleware.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ export const requestLoggerMiddleware: RequestHandler = (req, res, next) => {
4242
};
4343

4444
res.on('finish', () => {
45-
const { request, error } = loggingStore.getStore() ?? {};
46-
47-
if (!request?.type) return;
45+
const { error } = loggingStore.getStore() ?? {};
4846

4947
const logArgs = {
5048
response: {

dotcom-rendering/src/server/lib/logging-store.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export type DCRLoggingStore = {
1616
pageId: string;
1717
path: string;
1818
method: string;
19-
type?: string;
20-
platform?: string;
2119
};
2220
requestId: string;
2321
abTests: string;
@@ -29,18 +27,6 @@ export type DCRLoggingStore = {
2927

3028
export const loggingStore = new AsyncLocalStorage<DCRLoggingStore>();
3129

32-
export const recordTypeAndPlatform = (
33-
type: string,
34-
platform?: string,
35-
): void => {
36-
const { request } = loggingStore.getStore() ?? {};
37-
38-
if (request) {
39-
request.type = type;
40-
request.platform = platform;
41-
}
42-
};
43-
4430
export const recordError = (error: unknown): void => {
4531
const store = loggingStore.getStore();
4632

dotcom-rendering/src/server/lib/logging.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ const consoleLayout: Layout = {
5959
typeof fields.response.status === 'number'
6060
? fields.response.status
6161
: '[status missing]';
62-
const {
63-
platform = '[platform missing]',
64-
pageId = '[pageId missing]',
65-
type: requestType = '[request type missing]',
66-
} = fields.request;
62+
const requestPath = fields.request.path ?? '[path missing]';
6763

68-
return `${status} response for ${platform} ${requestType}: ${pageId}`;
64+
return `${status} response for ${requestPath}`;
6965
} else {
7066
return logEvent.data;
7167
}

0 commit comments

Comments
 (0)