Inferensys

Glossary

Span

A Span is the fundamental unit of work in distributed tracing, representing a named, timed operation that constitutes a single logical step in a request's execution path.
Product manager reviewing autonomous task execution dashboard on laptop, completed tasks visible, casual work session.
TOOL CALL INSTRUMENTATION

What is a Span?

A Span is the fundamental unit of work in distributed tracing, representing a named, timed operation representing a single logical step, such as the execution of a specific tool or API call by an agent.

In distributed tracing, a Span is a named, timed operation representing a single logical step in a request's path, such as an agent executing a specific tool call or API request. It records the operation's start and end time, a unique identifier, and a parent span context to establish causality within a Trace. Spans are the primary data structure for capturing latency, success status, and metadata for individual operations in a distributed system, enabling granular performance analysis and debugging.

For agentic observability, a Span instrumenting a tool call captures critical metadata as Span Attributes, including the tool name, parameters, HTTP status code, and any errors. Span Events can log significant moments like retries or cache hits. By correlating spans via Trace Correlation, engineers can reconstruct the complete execution flow of an autonomous agent, from initial planning through multiple external interactions, providing essential visibility into performance bottlenecks, error propagation, and dependency health within complex, multi-step workflows.

TOOL CALL INSTRUMENTATION

Core Components of a Span

A Span is the fundamental unit of work in distributed tracing, representing a single logical operation like a tool or API call. Its structure is defined by a set of core attributes that provide the context and detail necessary for observability.

01

Span Name & Operation

The Span Name is a human-readable identifier for the operation, such as call_tool:get_weather or api_request:POST /v1/chat/completions. It should be descriptive and consistent to enable effective aggregation and filtering in observability dashboards. The Operation itself is the timed execution block the span represents.

02

Span Context & Trace Correlation

The Span Context contains the essential identifiers for distributed tracing:

  • Trace ID: A globally unique 16-byte identifier shared by all spans in a single request's journey.
  • Span ID: A unique 8-byte identifier for this specific span.
  • Parent Span ID: The ID of the span that directly invoked this operation, establishing causality. This context is propagated via headers (e.g., traceparent) to external APIs, enabling Trace Correlation across service boundaries.
03

Timestamps & Duration

Spans are fundamentally defined by time. Two precise timestamps are recorded:

  • Start Timestamp: The nanosecond-precision UTC time when the operation began.
  • End Timestamp: The time when the operation completed (or failed). The Duration is calculated as (End Timestamp - Start Timestamp). This is the primary data point for performance analysis, allowing engineers to calculate metrics like average latency, P95, and P99 for tool calls.
04

Span Attributes (Tags)

Span Attributes are key-value pairs that provide descriptive metadata about the operation. For tool call instrumentation, critical attributes include:

  • tool.name: "stripe_create_charge"
  • http.method: "POST"
  • http.status_code: 429
  • `api.endpoint": "/v1/charges"
  • `error.type": "RateLimitExceeded" Attributes enable powerful slicing and dicing of trace data, answering questions like "Show me all failed calls to the payment API."
05

Span Status

The Span Status succinctly conveys the result of the operation. It consists of a Status Code and an optional Status Message.

  • UNSET: The default; the span status is not known.
  • OK: The operation completed successfully.
  • ERROR: The operation terminated with an error. A status of ERROR is a primary filter for identifying failing tool calls in monitoring systems, distinct from (but often accompanied by) error-related attributes.
06

Span Events (Logs)

Span Events are timestamped logs attached to a span, representing significant moments during the operation's lifecycle. Each event has a name and optional attributes. For a tool call, typical events include:

  • "retry.attempt" (with { "attempt.number": 2 })
  • "cache.hit"
  • "exception" (with { "exception.type": "TimeoutError", "exception.stacktrace": "..." }) Events provide a granular, sequential narrative within the span, crucial for debugging complex failures.
FUNDAMENTAL UNITS

Span vs. Trace: The Observability Hierarchy

A comparison of the two core data structures in distributed tracing, showing how individual Spans combine to form a complete Trace, which is essential for understanding agentic workflows.

Observability ConceptSpanTrace

Definition

A named, timed operation representing a single logical step (e.g., a tool call).

A directed acyclic graph of Spans representing the end-to-end journey of a request or agent task.

Scope

A single operation within a service or agent component.

The entire workflow across all services, agents, and external APIs.

Primary Purpose

To measure the duration and outcome of a specific action.

To provide context and causality for performance issues and errors across a system.

Data Structure

A single node with start/end times, status, attributes, and events.

A collection of linked nodes (Spans), forming a parent-child hierarchy or graph.

Unique Identifier

Span ID

Trace ID

Context Propagation

Carries its own Span ID and the overarching Trace ID.

Propagates the Trace ID across all service and network boundaries to link Spans.

Typical Root Cause

Reveals latency or failure in a specific tool, function, or database query.

Reveals which service or agent in a chain caused a bottleneck or failure.

Visualization

Appears as a single bar on a timeline or flame graph.

Appears as the entire flame graph or timeline view, showing all sequential and parallel Spans.

SPAN

Frequently Asked Questions

A Span is the fundamental unit of work in distributed tracing, representing a named, timed operation for a single logical step, such as an agent's execution of a specific tool or API call. These questions address its role in observability.

A Span is the fundamental unit of work in distributed tracing, representing a single, named, and timed operation within a larger request or transaction. It captures the lifecycle of a discrete logical step, such as an agent executing an external tool call, a database query, or an HTTP request to an API. Each span contains critical metadata including a unique Span ID, a Trace ID to link it to the broader request, a parent span ID to establish hierarchy, a name, start and end timestamps, a status code (e.g., OK, ERROR), and a set of Span Attributes (key-value pairs) for descriptive context. By instrumenting code to create spans, developers gain visibility into the timing, success, and dependencies of each component in a distributed system, enabling performance debugging and reliability analysis.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.