🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix: modify otel error marking on public api routes (#14185)
Steffen Schmitz8f2e30bbefa0
diff --git a/packages/shared/src/errors/BaseError.ts b/packages/shared/src/errors/BaseError.tsindex 742c01b818..23c8d3b072 100644--- a/packages/shared/src/errors/BaseError.ts+++ b/packages/shared/src/errors/BaseError.ts@@ -20,4 +20,8 @@ export class BaseError extends Error {Error.captureStackTrace(this);}}++ public isUserError(): boolean {+ return this.httpCode >= 400 && this.httpCode < 500;+ }}diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.tsindex 74a872a5b4..70691dca65 100644--- a/web/src/pages/api/public/ingestion.ts+++ b/web/src/pages/api/public/ingestion.ts@@ -151,18 +151,21 @@ export default async function handler(return res.status(207).json(result);});} catch (error: unknown) {- if (!(error instanceof UnauthorizedError)) {- logger.error("error_handling_ingestion_event", error);- traceException(error);- }-if (error instanceof BaseError) {+ if (!error.isUserError()) {+ logger.error(error);+ traceException(error);+ }+return res.status(error.httpCode).json({error: error.name,message: error.message,});}+ logger.error("error_handling_ingestion_event", error);+ traceException(error);+if (isPrismaException(error)) {return res.status(500).json({error: "Internal Server Error",diff --git a/web/src/pages/api/public/prompts.ts b/web/src/pages/api/public/prompts.tsindex 63add2d366..c3e8de9683 100644--- a/web/src/pages/api/public/prompts.ts+++ b/web/src/pages/api/public/prompts.ts@@ -108,16 +108,21 @@ export default async function handler(throw new MethodNotAllowedError();} catch (error: unknown) {- logger.error(error);- traceException(error);-if (error instanceof BaseError) {+ if (!error.isUserError()) {+ logger.error(error);+ traceException(error);+ }+return res.status(error.httpCode).json({error: error.name,message: error.message,});}+ logger.error(error);+ traceException(error);+if (isPrismaException(error)) {return res.status(500).json({error: "Internal Server Error",