Python APIbeeai

Core

Instrumentation

Python · Instrumentation

openinference-instrumentation-beeai

OpenInference BeeAI Instrumentation

Module
openinference.instrumentation.beeai
Version
0.1.36
Python
>=3.11,<3.15
Instruments
beeai-framework >= 0.1.51

Install

pip install openinference-instrumentation-beeai

Usage

Instrument once, at startup, before the library is used. The BeeAIInstrumentor reference below lists the options.

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

classSource ↗
class BeeAIInstrumentor(*args: Any = (), **kwargs: Any = {})

instrument

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

Parameters

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

skip_dep_check

Instrument even if the installed version of beeai-framework is outside the supported range.

uninstrument

method
def uninstrument() -> None

Stop tracing: undo the patches instrument() made. Inherited from OpenTelemetry’s BaseInstrumentor.

instrumentation_dependencies

methodSource ↗
def instrumentation_dependencies() -> Collection[str]

openinference.instrumentation.beeai.processors.base

Processor

classSource ↗
class Processor(event: RunContextStartEvent, meta: EventMeta)

Attributes

NameType and value
kindOpenInferenceSpanKindValues = OpenInferenceSpanKindValues.UNKNOWN
run_idmeta.trace.run_id
spanSpanWrapper(name=self.get_span_name(target_cls), kind=type(self).kind)

get_span_name

methodSource ↗
def get_span_name(target_cls: type) -> str

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

end

methodSource ↗
async def end(event: RunContextFinishEvent, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.tool

ToolProcessor

classSource ↗
class ToolProcessor(event: RunContextStartEvent, meta: EventMeta)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.locator

ProcessorLocator

classSource ↗
class ProcessorLocator

Attributes

NameType and value
entriesdict[type, type] = {}

locate

staticmethodSource ↗
def locate(data: Any, event: EventMeta) -> Processor

openinference.instrumentation.beeai.processors.embedding

EmbeddingModelProcessor

classSource ↗
class EmbeddingModelProcessor(
    event: RunContextStartEvent,
    meta: EventMeta,
)

get_span_name

methodSource ↗
def get_span_name(target_cls: type) -> str

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.chat

get_tool_parameters

functionSource ↗
def get_tool_parameters(tool: AnyTool) -> Dict[str, Any]

get_tools

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

ChatModelProcessor

classSource ↗
class ChatModelProcessor(event: RunContextStartEvent, meta: EventMeta)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.workflow

WorkflowProcessor

classSource ↗
class WorkflowProcessor(event: RunContextStartEvent, meta: EventMeta)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.requirement

RequirementProcessor

classSource ↗
class RequirementProcessor(event: RunContextStartEvent, meta: EventMeta)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.agents.base

AgentProcessor

classSource ↗
class AgentProcessor(event: RunContextStartEvent, meta: EventMeta)

openinference.instrumentation.beeai.processors.agents.tool_calling

ToolCallingAgentProcessor

classSource ↗
class ToolCallingAgentProcessor(AgentProcessor)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.agents.react

ReActAgentProcessor

classSource ↗
class ReActAgentProcessor(event: RunContextStartEvent, meta: EventMeta)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None

openinference.instrumentation.beeai.processors.agents.requirement_agent

RequirementAgentProcessor

classSource ↗
class RequirementAgentProcessor(
    event: RunContextStartEvent,
    meta: EventMeta,
)

update

methodSource ↗
async def update(event: Any, meta: EventMeta) -> None