Skip to main content

SpanStatus

Allowed status values for a Span.

Overview

SpanStatus defines the lifecycle states a span can be in. Every span has a status that indicates whether the operation completed, failed, or was interrupted. The default status is "unknown".

Import

from adaline_api.models.span_status import SpanStatus

Type Definition

SpanStatus is a str literal with the following allowed values:
ValueDescription
"success"The span completed successfully with the expected outcome.
"failure"The span encountered an error and did not complete.
"aborted"The span was terminated before completion due to an external signal (e.g., timeout).
"cancelled"The span was explicitly cancelled by the user or application logic.
"unknown"Status has not been set. This is the default.
SpanStatus does not include "pending". Unlike TraceStatus, spans represent discrete operations that are either complete or not — use "unknown" until the span resolves.

Usage

Setting status on a new span

span = trace.log_span(
    name="LLM Call",
    status="unknown",
    tags=["openai"],
)

Updating status after an LLM call

import json
from adaline_api.models.log_span_content import LogSpanContent
from adaline_api.models.log_span_model_content import LogSpanModelContent

try:
    response = openai.chat.completions.create(**params)
    span.update({
        "status": "success",
        "content": LogSpanContent(
            actual_instance=LogSpanModelContent(
                type="Model",
                provider="openai",
                model="gpt-4o",
                input=json.dumps(params),
                output=json.dumps(response.model_dump()),
            )
        ),
    })
except Exception:
    span.update({"status": "failure"})

Comparison with TraceStatus

ValueSpanStatusTraceStatus
"success"YesYes
"failure"YesYes
"aborted"YesYes
"cancelled"YesYes
"pending"NoYes
"unknown"YesYes

  • Span — the class that uses SpanStatus
  • TraceStatus — the equivalent status type for traces (includes "pending")
  • Trace — parent container for spans