mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Add OpenTelemetry error handling in StartServer.ts
This commit is contained in:
parent
4b5cc40542
commit
e0bcfd31bf
@ -27,6 +27,7 @@ import { AppVersion } from '../EnvironmentConfig';
|
||||
import ServerException from 'Common/Types/Exception/ServerException';
|
||||
import zlib from 'zlib';
|
||||
import CookieParser from 'cookie-parser';
|
||||
import { api } from '@opentelemetry/sdk-node';
|
||||
|
||||
// Make sure we have stack trace for debugging.
|
||||
Error.stackTraceLimit = Infinity;
|
||||
@ -186,6 +187,18 @@ const init: InitFunction = async (
|
||||
) => {
|
||||
logger.error(err);
|
||||
|
||||
// Mark span as error.
|
||||
|
||||
if (err) {
|
||||
const span = api.trace.getSpan(api.context.active());
|
||||
if (span) {
|
||||
span.setStatus({
|
||||
code: api.SpanStatusCode.ERROR,
|
||||
message: err.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (res.headersSent) {
|
||||
return next(err);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user