🪢 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(otel): add metrics for shallow trace events and sdk batches (#7325)
Hassieb Pakzad652036e8d3fa
diff --git a/web/src/features/otel/server/OtelIngestionProcessor.ts b/web/src/features/otel/server/OtelIngestionProcessor.tsindex 42d43c59ed..938fe84ddf 100644--- a/web/src/features/otel/server/OtelIngestionProcessor.ts+++ b/web/src/features/otel/server/OtelIngestionProcessor.ts@@ -7,6 +7,7 @@ import {redis,logger,instrumentAsync,+ recordIncrement,traceException,} from "@langfuse/shared/src/server";@@ -90,6 +91,11 @@ interface ResourceSpan {export class OtelIngestionProcessor {private seenTraces: Set<string> = new Set();private isInitialized = false;+ private traceEventCounts = {+ shallow: 0,+ rootSpanClosed: 0,+ traceUpdated: 0,+ };private readonly projectId: string;private readonly publicKey?: string;@@ -144,6 +150,22 @@ export class OtelIngestionProcessor {span.setAttribute("events_generated", finalEvents.length);+ this.traceEventCounts.shallow = Math.max(+ this.traceEventCounts.shallow -+ (allEvents.length - finalEvents.length),+ 0,+ );++ for (const key of Object.keys(+ this.traceEventCounts,+ ) as (keyof typeof this.traceEventCounts)[]) {+ recordIncrement(+ "langfuse.ingestion.otel.trace_create_event",+ this.traceEventCounts[key],+ { reason: key },+ );+ }+return finalEvents;} catch (error) {if (error instanceof ForbiddenError) {@@ -290,6 +312,10 @@ export class OtelIngestionProcessor {this.validatePublicKey(isLangfuseSDKSpans, scopeAttributes);+ if (isLangfuseSDKSpans) {+ recordIncrement("langfuse.otel.ingestion.langfuse_sdk_batch", 1);+ }+for (const span of scopeSpan?.spans ?? []) {const spanEvents = this.processSpan(span,@@ -462,6 +488,14 @@ export class OtelIngestionProcessor {};}+ if (isRootSpan) {+ this.traceEventCounts.rootSpanClosed += 1;+ } else if (hasTraceUpdates) {+ this.traceEventCounts.traceUpdated += 1;+ } else {+ this.traceEventCounts.shallow += 1;+ }+return {id: randomUUID(),type: "trace-create",