Skip to content

Commit 3534c70

Browse files
feat: add labels with API error details (#603)
1 parent 7e5b459 commit 3534c70

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib/http/middleware/error-handler.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import apmAgent from 'elastic-apm-node';
12
import createHttpError from 'http-errors';
23
import { scopedLogger } from '../../logger.js';
34
import type { ExtendedMiddleware } from '../../../types.js';
@@ -8,6 +9,11 @@ export const errorHandlerMw: ExtendedMiddleware = async (ctx, next) => {
89
try {
910
await next();
1011
} catch (error: unknown) {
12+
apmAgent.addLabels({
13+
gpErrorType: (error as { type?: string } | undefined)?.type || 'api_error',
14+
gpErrorMessage: (error as Error | undefined)?.message,
15+
});
16+
1117
if (createHttpError.isHttpError(error)) {
1218
ctx.status = error.status;
1319

0 commit comments

Comments
 (0)