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

# createOtelExtension

> TypeScript SDK reference

# createOtelExtension

▸ **createOtelExtension**(`opts?`): (`pi`: `PiExtensionApi`) => `void`

Creates a pi coding agent extension that emits OTEL spans for the full
agent lifecycle, conforming to the GenAI semantic conventions.

When `weave.init(...)` has been called, spans are automatically exported
to the Weave trace server at `/agents/otel/v1/traces`. Otherwise, pass a
custom `tracer` in `opts`.

#### Parameters

| Name   | Type                   |
| :----- | :--------------------- |
| `opts` | `OtelExtensionOptions` |

#### Returns

`fn`

▸ (`pi`): `void`

##### Parameters

| Name | Type             |
| :--- | :--------------- |
| `pi` | `PiExtensionApi` |

##### Returns

`void`

`Example`

```typescript twoslash theme={null}
// @noErrors
const resourceLoader = new DefaultResourceLoader({
  extensionFactories: [createOtelExtension()],
});
```

#### Defined in

[src/integrations/piCodingAgent.ts:654](https://github.com/wandb/weave/blob/9591aba8a5e77309ee0858e5ba94d31c1bd7e404/sdks/node/src/integrations/piCodingAgent.ts#L654)

***
