Skip to content

Commit 15fe429

Browse files
committed
feat: add clean-stack for better stack logging
1 parent fc06666 commit 15fe429

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"@sesamecare-oss/confit": "^2.2.1",
9191
"@sesamecare-oss/opentelemetry-node-metrics": "^1.1.0",
9292
"ajv": "^8.17.1",
93+
"clean-stack": "^5.2.0",
9394
"cookie-parser": "^1.4.7",
9495
"dotenv": "^16.4.5",
9596
"express": "^5.0.1",

src/telemetry/requestLogger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { RequestHandler, Request, Response, ErrorRequestHandler } from 'express';
22
import { getClientIp } from 'request-ip';
33
import { Histogram } from '@opentelemetry/api';
4+
import cleanStack from 'clean-stack';
45

56
import { ServiceError } from '../error.js';
67
import type { AnyServiceLocals, RequestWithApp, ServiceExpress, ServiceLocals } from '../types.js';
@@ -93,7 +94,7 @@ function finishLog<SLocals extends AnyServiceLocals = ServiceLocals<Configuratio
9394
if (error) {
9495
endLog.e = error.message;
9596
if (!(error instanceof ServiceError) || error.log_stack) {
96-
endLog.st = error.stack;
97+
endLog.st = cleanStack(error.stack);
9798
}
9899
if (!(error as ErrorWithStatus).expected_error) {
99100
unexpectedError = true;

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ __metadata:
927927
"@typescript-eslint/eslint-plugin": ^7.18.0
928928
"@typescript-eslint/parser": ^7.18.0
929929
ajv: ^8.17.1
930+
clean-stack: ^5.2.0
930931
coconfig: ^1.6.0
931932
cookie-parser: ^1.4.7
932933
dotenv: ^16.4.5

0 commit comments

Comments
 (0)