◆ NFRGate / Rule Reference

T4 — Errors marked on the span

medium 🔍 traces · both

When an external call fails, the span's status is explicitly set to error, not just logged separately, so trace-based error views pick it up.

Python Implementation

T4: when an external call fails, the span's status is explicitly set to
error — not just logged separately — so trace-based error views pick it up.
rubric_store/definitions/traces.yaml tags this `both`; the static half only
applies when there's a span to mark in the first place (is_wrapped_in_span),
and checks for a set_status(...) or record_exception(...) call — the two
standard OTel APIs for marking a span's error state — anywhere in the catch
block that handles the failure.

Java Implementation

T4 for Java: when an external call fails, the span's status is
explicitly set to error. Only applies when there's a span to mark
(is_wrapped_in_span), and checks the catch block for a `.setStatus(...)` or
`.recordException(...)` call — the two standard OTel Java API calls for
marking a span's error state.

Go Implementation

T4 for Go: when an external call fails, the span's status is explicitly
set to error. Only applies when a span was started earlier in this function
(is_wrapped_in_span, reusing T1/R1's textual-precedence check), and checks
the `if err != nil` block for a `.RecordError(...)` or `.SetStatus(...)`
call — Go OTel API's names for marking a span's error state.

Rust preview Implementation

T4 for Rust: errors inside a span are recorded on that span.

- The handler records the error explicitly (`span.record("error", ..)`,
  OTel `record_error` / `set_status`) -> pass.
- The fn is `#[instrument(err)]` and the handler propagates the error ->
  pass: tracing records the returned Err on the span automatically.
- The handler only logs an `error!`/`warn!` event -> unclear: exporters
  like tracing-opentelemetry attach the event, but whether the span is
  marked as errored depends on configuration.
- Otherwise -> fail.

Only handlers inside a span are graded (otherwise there is nothing to
mark), and only handlers with a body (not `let _ =` / `.ok();`).

PREVIEW: uncalibrated confidences, capped below the blocking threshold.
← All rules