dbt-labs/dbt-core · error

Telemetry hasn't been properly initialized. Missing span…

Error message

Telemetry hasn't been properly initialized. Missing span event attributes

What it means

Invariant expect in find_and_record_span_status: a span whose TelemetryAttributes extension type matches the expected one was found, but its span-event attributes were missing, meaning telemetry was never properly initialized for that span. This is an internal telemetry-setup defect, not a user-facing condition; spans without the matching attributes type are silently skipped instead.

Solutions

  1. Ensure telemetry initialization attaches TelemetryAttributes to spans at creation time
  2. Check that the span creation macro/path sets the event attributes extension
  3. Report as an internal bug in dbt-tracing span setup
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/dbt-tracing/src/span_info.rs:268 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/fec7381430fbda50. Report an issue: GitHub.

Appendix: source

Thrown at crates/dbt-tracing/src/span_info.rs:268

        }
    });
}

/// Records the status of a span for the closest span with the expected
/// `TelemetryAttributes` type starting from the current span and going up.
///
/// If no such span is found, this is a no-op.
pub fn find_and_record_span_status<A: AnyTelemetryEvent>(error_message: Option<&str>) {
    with_current_span(|span_ref| {
        // Find the closest span with the expected TelemetryAttributes type.
        // Scope iterator starts from the current span and goes up to the root.
        for span_ref in span_ref.scope() {
            let mut span_ext_mut = span_ref.extensions_mut();

            if span_ext_mut
                // Get the current attributes
                .get_mut::<TelemetryAttributes>()
                .expect("Telemetry hasn't been properly initialized. Missing span event attributes")
                // Try downcasting to the expected type
                .is::<A>()
            {
                // Found the expected attributes, call the updater and return
                record_span_status_on_ref(&mut span_ext_mut, error_message);
                return;
            }
        }
    });
}

/// Records the status and attributes of the given span.
///
/// If `error_message` is `None`, the status code will be set to `Ok`,
/// otherwise it will be set to `Error`.
///
/// The `attrs_updater` closure receives a mutable reference to the current
/// attributes and should modify them in place.

View on GitHub (pinned to 0267ce9170)