SigNoz/signoz · error

span not found

Error message

span not found

What it means

Thrown by GetSpanDetails in the smart traces module when the requested spanId cannot be located in the trace's span trees after a breadth-first search from every root span. The trace was found, but the specific span within it was not.

Source

Thrown at pkg/query-service/traces/smart/trace.go:64

	// If the target span is not found, return span not found error
	if targetSpan == nil {
		return nil, errors.New("span not found")
	}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Verify the spanId actually belongs to the given traceId by listing the trace's spans first
  2. Re-fetch the trace and use a spanId returned in that fresh response
  3. If spans are consistently missing, check sampling/rollup configuration for dropped intermediate spans
Defensive patterns

Strategy: try-catch

Validate before calling

trace, err := api.GetTrace(ctx, traceID)
if err != nil { return err }
found := false
for _, s := range trace.Spans {
    if s.SpanID == spanID { found = true; break }
}
if !found { return fmt.Errorf("span %s not in trace %s", spanID, traceID) }

Try / catch

details, err := api.GetSpanDetails(ctx, traceID, spanID)
if err != nil {
    if strings.Contains(err.Error(), "span not found") {
        // refresh trace or fall back to trace-level view
        return showTraceView(traceID)
    }
    return err
}

Prevention

When it happens

Trigger: Calling the span-details API with a spanId that does not belong to the supplied traceId, a stale spanId from before trace rollup/sampling, or a span whose parent chain is broken so it never attaches to a root tree (orphan span).

Common situations: UI deep-links to a span captured before retention/rollup removed it; copying spanId across environments (dev spanId against prod trace); tail-sampling dropping intermediate spans so BFS from roots never reaches the target.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/1339f1960c4679d5. Report an issue: GitHub.