> ## 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.

# Span Event • Rust AI Agent SDK

> SpanEvent: An event within a span.

# SpanEvent

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

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

An event within a span.

## Fields

| Name         | Type                | Description                               |
| ------------ | ------------------- | ----------------------------------------- |
| `name`       | `String`            | Event name                                |
| `timestamp`  | `Duration`          | Timestamp (as duration since trace start) |
| `attributes` | `HashMap&lt;String` | Attributes                                |
| `serde_json` | `:Value&gt;`        | Attributes                                |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(name: impl Into<String>, timestamp: Duration) -> Self
```

Create a new event.

**Parameters:**

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

### `with_attribute`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_attribute(mut self, key: impl Into<String>, value: impl Serialize) -> Self
```

Add an attribute.

**Parameters:**

| Name    | Type                      |
| ------- | ------------------------- |
| `key`   | `impl Into&lt;String&gt;` |
| `value` | `impl Serialize`          |

## Source

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