{"record":{"id":"86605ddb1caaed1f","repo":"mlflow/mlflow","slug":"no-trace-found-for-span-span-name-skipping","errorCode":null,"errorMessage":"No trace found for span ${span.name}. Skipping.","messagePattern":"No trace found for span (.+?)\\. Skipping\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"libs/typescript/core/src/exporters/mlflow.ts","lineNumber":125,"sourceCode":"    const traceManager = InMemoryTraceManager.getInstance();\n\n    executeOnSpanEndHooks(span);\n\n    // Only trigger trace export for root span completion\n    if (span.parentSpanContext?.spanId) {\n      return;\n    }\n\n    // Update trace info\n    const traceId = traceManager.getMlflowTraceIdFromOtelId(span.spanContext().traceId);\n    if (!traceId) {\n      console.warn(`No trace ID found for span ${span.name}. Skipping.`);\n      return;\n    }\n\n    const trace = InMemoryTraceManager.getInstance().getTrace(traceId);\n    if (!trace) {\n      console.warn(`No trace found for span ${span.name}. Skipping.`);\n      return;\n    }\n\n    this.updateTraceInfo(trace.info, span);\n    // Aggregate token usage from all spans and add to trace metadata\n    const allSpans = Array.from(trace.spanDict.values());\n    const aggregatedUsage = aggregateUsageFromSpans(allSpans);\n    if (aggregatedUsage) {\n      trace.info.traceMetadata[TraceMetadataKey.TOKEN_USAGE] = JSON.stringify(aggregatedUsage);\n    }\n\n    this._exporter.export([span], (_) => {});\n  }\n\n  /**\n   * Update the trace info with the span end time and status.\n   * @param trace The trace to update\n   * @param span The span to update the trace with","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/libs/typescript/core/src/exporters/mlflow.ts#L107-L143","documentation":"This warning is emitted from the MLflow OTel exporter's onEnd hook in libs/typescript/core/src/exporters/mlflow.ts. The exporter successfully resolved an MLflow trace ID from the span's OTel trace ID, but InMemoryTraceManager.getTrace(traceId) returned nothing — the MLflow trace object itself is missing from the in-memory store. Since the trace object is needed to update trace info and aggregate token usage, the span is skipped. It is a console.warn, not a thrown error.","triggerScenarios":"The OTel->MLflow ID mapping still exists but the trace was removed from the manager's store before the span ended: the trace was flushed/deleted, the manager was reset/cleared between span start and end, or two different manager instances hold inconsistent state (mapping in one, traces in another).","commonSituations":"Long-lived spans outliving trace retention; explicit trace-manager cleanup/reset (tests, serverless cold-warm transitions) mid-span; duplicate in-memory singletons due to multiple copies of the package in node_modules or split bundles; calling trace-end/flush APIs that evict the trace while child spans are still finishing.","solutions":["End all child spans before ending/flushing the MLflow trace so the trace object still exists in the manager.","Ensure a single InMemoryTraceManager instance (dedupe package copies, avoid re-initializing the module).","Avoid resetting/clearing the trace manager while spans are in flight; sequence teardown after all spans end.","If traces are being evicted too eagerly, check retention/flush configuration or keep the parent trace alive until the last span completes."],"exampleFix":"// before\ntraceManager.reset(); // wipes traces while spans still open\nspan.end();\n\n// after\nspan.end();\ntraceManager.reset();","handlingStrategy":"validation","validationCode":"const manager = InMemoryTraceManager.getInstance();\nconst traceId = manager.getMlflowTraceIdFromOtelId(span.spanContext().traceId);\nif (traceId && !manager.getTrace(traceId)) {\n  console.error(`Span ${span.name} will be skipped: MLflow trace ${traceId} already evicted.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call trace end/flush only after all spans have ended.","Do not reset or clear the trace manager mid-span.","Verify only one InMemoryTraceManager instance exists (bundle/dedupe check).","Extend trace retention if long-running spans are outliving the trace."],"tags":["tracing","opentelemetry","typescript","span-export","missing-trace"],"backgroundTag":"trace-not-found","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}