mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
Add stack.process-id to OpenTelemetry attributes
This commit is contained in:
parent
30e27906ec
commit
2ac8cb8542
@ -52,6 +52,12 @@ function catchError(error: unknown, requestId: string): StatusError {
|
||||
return new InternalServerError(error, requestId);
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique identifier for the current process. This is used to correlate logs in serverless environments that allow
|
||||
* multiple concurrent requests to be handled by the same instance.
|
||||
*/
|
||||
const processId = generateSecureRandomString(80);
|
||||
|
||||
/**
|
||||
* Catches any errors thrown in the handler and returns a 500 response with the thrown error message. Also logs the
|
||||
* request details.
|
||||
@ -65,6 +71,7 @@ export function handleApiRequest(handler: (req: NextRequest, options: any, reque
|
||||
"stack.request.request-id": requestId,
|
||||
"stack.request.method": req.method,
|
||||
"stack.request.url": req.url,
|
||||
"stack.process-id": processId,
|
||||
},
|
||||
}, async (span) => {
|
||||
// Set Sentry scope to include request details
|
||||
|
||||
Loading…
Reference in New Issue
Block a user