# aspire otel spans command

## Name

`aspire otel spans` - View spans from the Dashboard telemetry API.

## Synopsis

```bash title="Aspire CLI"
aspire otel spans [resource] [options]
```

<AsciinemaPlayer
  src="/casts/aspire-otel-spans.cast"
  poster="npt:0:01"
  rows={29}
  loop={false}
  speed={.5}
/>

## Description

The `aspire otel spans` command retrieves and displays distributed trace spans collected by the Aspire Dashboard. Spans represent individual units of work within a distributed trace, such as HTTP requests or database calls. You can filter spans by resource name, trace ID, or error status. Use `--follow` to stream spans in real-time as they arrive.

## Arguments

- **`[resource]`**

  Filter by resource name. When specified, only spans from the matching resource are shown. Supports both exact instance names and base resource names (which match all replicas).

## Options

The following options are available:

- **`--apphost <apphost>`**

  The path to the Aspire AppHost project file.

- **`-f, --follow`**

  Stream telemetry in real-time as it arrives.

- **`--format <Table|Json>`**

  Output format (Table or Json).

- **`-n, --limit <limit>`**

  Maximum number of items to return.

- **`--trace-id <trace-id>`**

  Filter by trace ID.

- **`--has-error <true|false>`**

  Filter by error status (true to show only errors, false to exclude errors).

- <Include relativePath="reference/cli/includes/option-help.md" />

- <Include relativePath="reference/cli/includes/option-log-level.md" />

- <Include relativePath="reference/cli/includes/option-non-interactive.md" />

- <Include relativePath="reference/cli/includes/option-nologo.md" />

- <Include relativePath="reference/cli/includes/option-banner.md" />

- <Include relativePath="reference/cli/includes/option-wait.md" />

## Examples

- View all spans:

  ```bash title="Aspire CLI"
  aspire otel spans
  ```

- View spans for a specific resource:

  ```bash title="Aspire CLI"
  aspire otel spans apiservice
  ```

- Stream spans in real-time:

  ```bash title="Aspire CLI"
  aspire otel spans --follow
  ```

- View only error spans:

  ```bash title="Aspire CLI"
  aspire otel spans --has-error true
  ```

- View spans for a specific trace in JSON format:

  ```bash title="Aspire CLI"
  aspire otel spans --trace-id abc123 --format Json
  ```

## See also

- [aspire otel command](../aspire-otel/)
- [aspire otel logs command](../aspire-otel-logs/)
- [aspire otel traces command](../aspire-otel-traces/)