# openinference-instrumentation-instructor

**Python · Instrumentation**

OpenInference Instructor Instrumentation

- **Module**: `openinference.instrumentation.instructor`
- **Version**: 0.1.36
- **Python**: >=3.10, <3.14
- **Instruments**: `instructor >= 1.3.7`

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

## Install

```sh
pip install openinference-instrumentation-instructor
```

## Usage

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

```python
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation import TraceConfig
from openinference.instrumentation.instructor import InstructorInstrumentor

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

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

## `openinference.instrumentation.instructor`

### `InstructorInstrumentor`

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

```python
class InstructorInstrumentor(BaseInstrumentor)
```

#### `instrument`

_method_

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

Start tracing `instructor`: 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 `instructor` 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-instructor/src/openinference/instrumentation/instructor/__init__.py#L27-L28)

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