mlflow/mlflow · warning

No trace found for span ${span.name}. Skipping.

Error message

No trace found for span ${span.name}. Skipping.

What it means

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.

Source

Thrown at libs/typescript/core/src/exporters/mlflow.ts:125

    const traceManager = InMemoryTraceManager.getInstance();

    executeOnSpanEndHooks(span);

    // Only trigger trace export for root span completion
    if (span.parentSpanContext?.spanId) {
      return;
    }

    // Update trace info
    const traceId = traceManager.getMlflowTraceIdFromOtelId(span.spanContext().traceId);
    if (!traceId) {
      console.warn(`No trace ID found for span ${span.name}. Skipping.`);
      return;
    }

    const trace = InMemoryTraceManager.getInstance().getTrace(traceId);
    if (!trace) {
      console.warn(`No trace found for span ${span.name}. Skipping.`);
      return;
    }

    this.updateTraceInfo(trace.info, span);
    // Aggregate token usage from all spans and add to trace metadata
    const allSpans = Array.from(trace.spanDict.values());
    const aggregatedUsage = aggregateUsageFromSpans(allSpans);
    if (aggregatedUsage) {
      trace.info.traceMetadata[TraceMetadataKey.TOKEN_USAGE] = JSON.stringify(aggregatedUsage);
    }

    this._exporter.export([span], (_) => {});
  }

  /**
   * Update the trace info with the span end time and status.
   * @param trace The trace to update
   * @param span The span to update the trace with

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. End all child spans before ending/flushing the MLflow trace so the trace object still exists in the manager.
  2. Ensure a single InMemoryTraceManager instance (dedupe package copies, avoid re-initializing the module).
  3. Avoid resetting/clearing the trace manager while spans are in flight; sequence teardown after all spans end.
  4. If traces are being evicted too eagerly, check retention/flush configuration or keep the parent trace alive until the last span completes.

Example fix

// before
traceManager.reset(); // wipes traces while spans still open
span.end();

// after
span.end();
traceManager.reset();
Defensive patterns

Strategy: validation

Validate before calling

const manager = InMemoryTraceManager.getInstance();
const traceId = manager.getMlflowTraceIdFromOtelId(span.spanContext().traceId);
if (traceId && !manager.getTrace(traceId)) {
  console.error(`Span ${span.name} will be skipped: MLflow trace ${traceId} already evicted.`);
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/86605ddb1caaed1f. Report an issue: GitHub.