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

# Tracer • Rust AI Agent SDK

> Tracer: Global tracer for convenience.

# Tracer

> Defined in the [**trace**](../modules/trace) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Global tracer for convenience.

## Fields

| Name        | Type                                                               | Description   |
| ----------- | ------------------------------------------------------------------ | ------------- |
| `traces`    | `Arc&lt;RwLock&lt;HashMap&lt;String`                               | Active traces |
| `exporters` | `Arc&lt;RwLock&lt;Vec&lt;Box&lt;dyn TraceExporter&gt;&gt;&gt;&gt;` | Exporters     |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new() -> Self
```

Create a new tracer.

### `add_exporter`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn add_exporter(&self, exporter: impl TraceExporter + 'static) -> ()
```

Add an exporter.

**Parameters:**

| Name       | Type                           |
| ---------- | ------------------------------ |
| `exporter` | `impl TraceExporter + 'static` |

### `start_trace`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn start_trace(&self, name: impl Into<String>) -> String
```

Start a new trace.

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `name` | `impl Into&lt;String&gt;` |

### `end_trace`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn end_trace(&self, trace_id: &str) -> ()
```

End a trace and export.

**Parameters:**

| Name       | Type   |
| ---------- | ------ |
| `trace_id` | `&str` |

### `start_span`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn start_span(&self, trace_id: &str, name: impl Into<String>, kind: SpanKind) -> Option<String>
```

Start a span in a trace.

**Parameters:**

| Name       | Type                      |
| ---------- | ------------------------- |
| `trace_id` | `&str`                    |
| `name`     | `impl Into&lt;String&gt;` |
| `kind`     | `SpanKind`                |

### `end_span`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn end_span(&self, trace_id: &str, span_id: &str) -> ()
```

End a span in a trace.

**Parameters:**

| Name       | Type   |
| ---------- | ------ |
| `trace_id` | `&str` |
| `span_id`  | `&str` |

### `trace_count`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn trace_count(&self) -> usize
```

Get trace count.

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/trace/mod.rs#L382">
  `praisonai/src/trace/mod.rs` at line 382
</Card>

***

## Related Documentation

<CardGroup cols={2}>
  <Card title="Rust Tracing" icon="chart-line" href="/docs/rust/tracing" />

  <Card title="Rust Telemetry" icon="signal" href="/docs/rust/telemetry" />
</CardGroup>
