> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# BotTracing

> Interface exported by @botmesh/core.

Defined in: [telemetry/types.ts:162](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L162)

Tracing facade of a bot (`bot.tracing`), also used by plugins (`@botmesh/ai`). Without
`BotConfig.telemetry` it is a no-op (`enabled === false`).

## Properties

### enabled

```ts theme={null}
readonly enabled: boolean;
```

Defined in: [telemetry/types.ts:163](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L163)

## Methods

### startSpan()

```ts theme={null}
startSpan(name, options?): BotSpan;
```

Defined in: [telemetry/types.ts:164](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L164)

#### Parameters

| Parameter | Type |
| - | - |
| `name` | `string` |
| `options?` | [`SpanOptions`](https://botmesh.afaya.com.co/api/core/interfaces/SpanOptions) |

#### Returns

[`BotSpan`](https://botmesh.afaya.com.co/api/core/interfaces/BotSpan)

***

### activeSpan()

```ts theme={null}
activeSpan(): BotSpan | undefined;
```

Defined in: [telemetry/types.ts:166](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L166)

The span the current async chain runs under (core context), if any.

#### Returns

[`BotSpan`](https://botmesh.afaya.com.co/api/core/interfaces/BotSpan) | `undefined`

***

### withSpan()

```ts theme={null}
withSpan<T>(span, fn): T;
```

Defined in: [telemetry/types.ts:168](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L168)

Run `fn` with `span` active (core context and the backend's). Returns `fn`'s value unchanged.

#### Type Parameters

| Type Parameter |
| - |
|  `T` |

#### Parameters

| Parameter | Type |
| - | - |
| `span` | [`BotSpan`](https://botmesh.afaya.com.co/api/core/interfaces/BotSpan) |
| `fn` | () => `T` |

#### Returns

`T`

***

### trace()

```ts theme={null}
trace<T>(
   name, 
   options, 
   fn
): T;
```

Defined in: [telemetry/types.ts:174](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L174)

Start a span, run `fn` inside it and end it when `fn` returns or its promise settles
(a throw/rejection sets status `error` and records the sanitized exception). Returns
`fn`'s own value or promise — never a derived one.

#### Type Parameters

| Type Parameter |
| - |
|  `T` |

#### Parameters

| Parameter | Type |
| - | - |
| `name` | `string` |
| `options` | [`SpanOptions`](https://botmesh.afaya.com.co/api/core/interfaces/SpanOptions) |
| `fn` | (`span`) => `T` |

#### Returns

`T`

***

### recordError()

```ts theme={null}
recordError(span, error): void;
```

Defined in: [telemetry/types.ts:176](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L176)

Record a sanitized error on `span` (status `error`, `error.type`, exception event).

#### Parameters

| Parameter | Type |
| - | - |
| `span` | [`BotSpan`](https://botmesh.afaya.com.co/api/core/interfaces/BotSpan) |
| `error` | `unknown` |

#### Returns

`void`

***

### idAttribute()

```ts theme={null}
idAttribute(id): string | undefined;
```

Defined in: [telemetry/types.ts:178](https://github.com/andresayac/botmesh/blob/main/packages/core/src/telemetry/types.ts#L178)

Apply the `ids` policy to an id (`undefined` under `'omit'`). For plugins that tag their own spans.

#### Parameters

| Parameter | Type |
| - | - |
| `id` | `string` |

#### Returns

`string` | `undefined`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.