> ## Documentation Index
> Fetch the complete documentation index at: https://www.adaline.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# TraceStatus

> Allowed status values for a trace.

# TraceStatus

The set of allowed status values for a trace. Used to indicate the outcome of a traced operation.

## Import

```typescript theme={null}
import type { TraceStatus } from '@adaline/client';
```

## Type Definition

```typescript theme={null}
type TraceStatus = 'success' | 'failure' | 'aborted' | 'cancelled' | 'pending' | 'unknown';
```

## Values

| Value         | Description                                                                               |
| ------------- | ----------------------------------------------------------------------------------------- |
| `'success'`   | The traced operation completed successfully.                                              |
| `'failure'`   | The operation failed due to an error or exception.                                        |
| `'aborted'`   | The operation was aborted before completion (e.g. timeout).                               |
| `'cancelled'` | The operation was explicitly cancelled by the caller or user.                             |
| `'pending'`   | The operation is still in progress. Only available for traces, not spans.                 |
| `'unknown'`   | Status has not been determined. **This is the default** when no status is explicitly set. |

<Note>
  The default status for a newly created trace is `'unknown'`. You should update it to a terminal status (`'success'`, `'failure'`, `'aborted'`, or `'cancelled'`) before calling `trace.end()`.
</Note>

***

## Examples

### Setting Status on a Trace

```typescript theme={null}
import { Adaline } from '@adaline/client';

const adaline = new Adaline();
const monitor = adaline.initMonitor({ projectId: 'my-project' });

const trace = monitor.logTrace({
  name: 'Chat Request',
  tags: ['chat']
});

try {
  const result = await handleRequest();
  trace.update({ status: 'success' });
} catch (error) {
  trace.update({ status: 'failure' });
} finally {
  trace.end();
}
```

### Handling Cancellation and Abort

```typescript theme={null}
async function handleWithTimeout(signal: AbortSignal) {
  const trace = monitor.logTrace({ name: 'Timed Request' });

  try {
    const result = await fetchWithSignal(signal);
    trace.update({ status: 'success' });
    return result;
  } catch (error) {
    if (signal.aborted) {
      trace.update({ status: 'aborted' });
    } else {
      trace.update({ status: 'failure' });
    }
    throw error;
  } finally {
    trace.end();
  }
}
```

### Using Pending for Long-Running Operations

```typescript theme={null}
const trace = monitor.logTrace({
  name: 'Batch Processing',
  tags: ['batch']
});

trace.update({ status: 'pending' });

for (const item of items) {
  await processItem(item);
}

trace.update({ status: 'success' });
trace.end();
```

### Conditional Status Logic

```typescript theme={null}
import type { TraceStatus } from '@adaline/client';

function resolveStatus(error?: Error, cancelled?: boolean): TraceStatus {
  if (cancelled) return 'cancelled';
  if (error) return 'failure';
  return 'success';
}

trace.update({ status: resolveStatus(error, wasCancelled) });
```

***

## Related

* [Trace](/docs/reference/sdk/v2/typescript/classes/trace) — class that uses `TraceStatus` in `trace.update()`
* [Monitor](/docs/reference/sdk/v2/typescript/classes/monitor) — creates traces via `monitor.logTrace()`
* [Span](/docs/reference/sdk/v2/typescript/classes/span) — uses a similar `SpanStatus` type (which excludes `'pending'`)
