···
1
1
import { registerOTel } from "@vercel/otel";
2
2
import { PgInstrumentation } from "@opentelemetry/instrumentation-pg";
3
3
+
import type { Instrumentation } from "next";
3
4
4
5
export function register() {
5
6
registerOTel({
···
7
8
instrumentations: [new PgInstrumentation()],
8
9
});
9
10
}
11
11
+
12
12
+
export const onRequestError: Instrumentation.onRequestError = async (err, request, context) => {
13
13
+
const error = err as Error & { digest?: string; cause?: unknown };
14
14
+
console.error("[onRequestError]", {
15
15
+
error: {
16
16
+
name: error.name,
17
17
+
message: error.message,
18
18
+
digest: error.digest,
19
19
+
cause: error.cause,
20
20
+
stack: error.stack,
21
21
+
},
22
22
+
request: {
23
23
+
method: request.method,
24
24
+
path: request.path,
25
25
+
},
26
26
+
context,
27
27
+
});
28
28
+
};