🪢 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
chore: move span tagging to top of ingestion processing (#3700)
Steffen Schmitzfa7cdca96bed
diff --git a/web/src/pages/api/public/ingestion.ts b/web/src/pages/api/public/ingestion.tsindex 7c60557bcf..a87d6c5435 100644--- a/web/src/pages/api/public/ingestion.ts+++ b/web/src/pages/api/public/ingestion.ts@@ -89,6 +89,23 @@ export default async function handler(* VALIDATION ***************/await runMiddleware(req, res, cors);++ // add context of api call to the span+ const currentSpan = getCurrentSpan();++ // get x-langfuse-xxx headers and add them to the span+ Object.keys(req.headers).forEach((header) => {+ if (+ header.toLowerCase().startsWith("x-langfuse") ||+ header.toLowerCase().startsWith("x_langfuse")+ ) {+ currentSpan?.setAttributes({+ [`langfuse.header.${header.slice(10).toLowerCase()}`]:+ req.headers[header],+ });+ }+ });+if (req.method !== "POST") throw new MethodNotAllowedError();// CHECK AUTH FOR ALL EVENTS@@ -125,21 +142,6 @@ export default async function handler(parsedSchema.success ? parsedSchema.data.batch.length : 0,);- // add context of api call to the span- const currentSpan = getCurrentSpan();-- // get x-langfuse-xxx headers and add them to the span- Object.keys(req.headers).forEach((header) => {- if (- header.toLowerCase().startsWith("x-langfuse") ||- header.toLowerCase().startsWith("x_langfuse")- ) {- currentSpan?.setAttributes({- [header]: req.headers[header],- });- }- });-// add number of events to the spanparsedSchema.data? currentSpan?.setAttribute("event_count", parsedSchema.data.batch.length)