# openinference-instrumentation-beeai

**Python · Instrumentation**

OpenInference BeeAI Instrumentation

- **Module**: `openinference.instrumentation.beeai`
- **Version**: 0.1.37
- **Python**: >=3.11,<3.15
- **Instruments**: `beeai-framework >= 0.1.51`

[PyPI](https://pypi.org/project/openinference-instrumentation-beeai/) · [README](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/README.md) · [Source](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-beeai)

## Install

```sh
pip install openinference-instrumentation-beeai
```

## Usage

Instrument once, at startup, before the library is used. The [`BeeAIInstrumentor`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.BeeAIInstrumentor) reference below lists the options.

```python
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation import TraceConfig
from openinference.instrumentation.beeai import BeeAIInstrumentor

tracer_provider = TracerProvider()
# ...add a span processor that exports to Phoenix or any OTLP backend.

BeeAIInstrumentor().instrument(
    tracer_provider=tracer_provider,
    config=TraceConfig(hide_inputs=True),  # optional
)
```

## `openinference.instrumentation.beeai`

### `BeeAIInstrumentor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/__init__.py#L34-L141)

```python
class BeeAIInstrumentor(*args: Any = (), **kwargs: Any = {})
```

#### `instrument`

_method_

```python
def instrument(
    *,
    tracer_provider: Optional[TracerProvider] = None,
    config: Optional[TraceConfig] = None,
    skip_dep_check: bool = False,
) -> None
```

Start tracing `beeai-framework`: patch it so its calls make OpenInference spans. Calling it again does nothing. Inherited from OpenTelemetry’s [`BaseInstrumentor`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/base/instrumentor.html).

**Parameters**

| Name | Description |
| - | - |
| `tracer_provider` | The tracer provider the spans are made with. Defaults to the global one, `opentelemetry.trace.get_tracer_provider()`. |
| `config` | What the spans record: hide inputs, outputs or messages, or limit image sizes. Defaults to `TraceConfig()`, which reads the `OPENINFERENCE_*` environment variables. See [`TraceConfig`](https://openinf.dev/python/openinference-instrumentation.html.md#openinference.instrumentation.TraceConfig). |
| `skip_dep_check` | Instrument even if the installed version of `beeai-framework` is outside the supported range. |

#### `uninstrument`

_method_

```python
def uninstrument() -> None
```

Stop tracing: undo the patches `instrument()` made. Inherited from OpenTelemetry’s [`BaseInstrumentor`](https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/base/instrumentor.html).

#### `instrumentation_dependencies`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/__init__.py#L43-L44)

```python
def instrumentation_dependencies() -> Collection[str]
```

## `openinference.instrumentation.beeai.processors.base`

### `Processor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/base.py#L18-L65)

```python
class Processor(event: RunContextStartEvent, meta: EventMeta)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.base.Processor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.UNKNOWN` |
| [`run_id`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.base.Processor.run_id) | `meta.trace.run_id` |
| [`span`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.base.Processor.span) | `SpanWrapper(name=self.get_span_name(target_cls), kind=type(self).kind)` |

#### `get_span_name`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/base.py#L21-L22)

```python
def get_span_name(target_cls: type) -> str
```

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/base.py#L44-L49)

```python
async def update(event: Any, meta: EventMeta) -> None
```

#### `end`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/base.py#L51-L65)

```python
async def end(event: RunContextFinishEvent, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.tool`

### `ToolProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/tool.py#L19-L74)

```python
class ToolProcessor(event: RunContextStartEvent, meta: EventMeta)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.tool.ToolProcessor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.TOOL` |

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/tool.py#L40-L74)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.locator`

### `ProcessorLocator`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/locator.py#L10-L106)

```python
class ProcessorLocator
```

**Attributes**

| Name | Type and value |
| - | - |
| [`entries`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.locator.ProcessorLocator.entries) | `dict[type, type] = {}` |

#### `locate`

_staticmethod_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/locator.py#L86-L106)

```python
def locate(data: Any, event: EventMeta) -> Processor
```

## `openinference.instrumentation.beeai.processors.embedding`

### `EmbeddingModelProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/embedding.py#L24-L89)

```python
class EmbeddingModelProcessor(
    event: RunContextStartEvent,
    meta: EventMeta,
)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.embedding.EmbeddingModelProcessor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.EMBEDDING` |

#### `get_span_name`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/embedding.py#L27-L29)

```python
def get_span_name(target_cls: type) -> str
```

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/embedding.py#L57-L89)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.chat`

### `get_tool_parameters`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/chat.py#L40-L46)

```python
def get_tool_parameters(tool: AnyTool) -> Dict[str, Any]
```

### `get_tools`

_function_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/chat.py#L49-L55)

```python
def get_tools(
    tools: list[AnyTool],
) -> Generator[Tuple[str, str], None, None]
```

### `ChatModelProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/chat.py#L58-L171)

```python
class ChatModelProcessor(event: RunContextStartEvent, meta: EventMeta)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.chat.ChatModelProcessor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.LLM` |

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/chat.py#L77-L156)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.workflow`

### `WorkflowProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/workflow.py#L28-L103)

```python
class WorkflowProcessor(event: RunContextStartEvent, meta: EventMeta)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.workflow.WorkflowProcessor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.CHAIN` |

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/workflow.py#L53-L67)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.requirement`

### `RequirementProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/requirement.py#L16-L67)

```python
class RequirementProcessor(event: RunContextStartEvent, meta: EventMeta)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.requirement.RequirementProcessor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.UNKNOWN` |

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/requirement.py#L53-L67)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.agents.base`

### `AgentProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/base.py#L15-L34)

```python
class AgentProcessor(event: RunContextStartEvent, meta: EventMeta)
```

**Attributes**

| Name | Type and value |
| - | - |
| [`kind`](https://openinf.dev/python/openinference-instrumentation-beeai.html.md#openinference.instrumentation.beeai.processors.agents.base.AgentProcessor.kind) | `OpenInferenceSpanKindValues = OpenInferenceSpanKindValues.AGENT` |

## `openinference.instrumentation.beeai.processors.agents.tool_calling`

### `ToolCallingAgentProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/tool_calling.py#L14-L34)

```python
class ToolCallingAgentProcessor(AgentProcessor)
```

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/tool_calling.py#L15-L34)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.agents.react`

### `ReActAgentProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/react.py#L12-L77)

```python
class ReActAgentProcessor(event: RunContextStartEvent, meta: EventMeta)
```

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/react.py#L17-L77)

```python
async def update(event: Any, meta: EventMeta) -> None
```

## `openinference.instrumentation.beeai.processors.agents.requirement_agent`

### `RequirementAgentProcessor`

_class_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/requirement_agent.py#L17-L71)

```python
class RequirementAgentProcessor(
    event: RunContextStartEvent,
    meta: EventMeta,
)
```

#### `update`

_method_ · [Source](https://github.com/Arize-ai/openinference/blob/main/python/instrumentation/openinference-instrumentation-beeai/src/openinference/instrumentation/beeai/processors/agents/requirement_agent.py#L22-L51)

```python
async def update(event: Any, meta: EventMeta) -> None
```
