Registry / observability / openinference-instrumentation-instructor

openinference-instrumentation-instructor

JSON →
library0.1.17pypypi✓ verified 83d ago

OpenTelemetry instrumentation for the instructor library (Python), enabling tracing of LLM calls and structured extraction for observability with Phoenix and other OpenInference-compatible backends. Current version: 0.1.14. Release cadence: irregular, part of the openinference monorepo.

pip install openinference-instrumentation-instructor
INSTALL
IMPORT
SIG · OPENINFERENCE-INST
O
openinference-instrumentation-instructor
observabilitypythonv0.1.17
Install
2.9s avg
Import
559ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.17 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.478s · 24.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.9s · import 0.416s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InstructorInstrumentor
from openinference.instrumentation.instructor import InstructorInstrumentor
from openinference_instrumentation_instructor import InstructorInstrumentor
Incorrect import path with hyphens in module name; use dots.

Instrument instructor to trace LLM calls and structured extraction. Ensure instructor and openai are installed.

import instructor from openinference.instrumentation.instructor import InstructorInstrumentor # Instrument before using instructor InstructorInstrumentor().instrument() # Now use instructor normally client = instructor.from_openai(openai.OpenAI(api_key=os.environ.get('OPENAI_API_KEY', ''))) # Example: extract structured data import pydantic class User(pydantic.BaseModel): name: str age: int user = client.chat.completions.create(model="gpt-4o", response_model=User, messages=[{"role": "user", "content": "John Doe is 30"}]) print(user.name, user.age)
Debug
Known issues
gotchaThe import path uses dots, not hyphens: 'openinference.instrumentation.instructor' not 'openinference_instrumentation_instructor'. Hyphenated package name on PyPI maps to underscore in import but correct is dotted.
fix
Use: from openinference.instrumentation.instructor import InstructorInstrumentor
affects: all
gotchaInstrumentation must be called before any instructor client usage. If you instrument after creating a client, spans will not be captured.
fix
Call InstructorInstrumentor().instrument() at the top of your application, before importing or creating instructor clients.
affects: all
breakingBreaking change when upgrading from openinference-instrumentation-instructor <0.1.0: The module name changed from openinference_instrumentation_instructor to openinference.instrumentation.instructor.
fix
Update import: from openinference.instrumentation.instructor import InstructorInstrumentor
affects: <0.1.0
Errors
Common errors & fixes
ImportError: cannot import name 'InstructorInstrumentor' from 'openinference_instrumentation_instructor'
Using hyphens in module path (incorrect import path).
fix
Use: from openinference.instrumentation.instructor import InstructorInstrumentor
ModuleNotFoundError: No module named 'openinference_instrumentation_instructor'
Package not installed or using incorrect import name (should be dotted).
fix
Install: pip install openinference-instrumentation-instructor. Then import: from openinference.instrumentation.instructor import InstructorInstrumentor
Opentelemetry span not created for instructor calls
Instrumentation was called after creating the instructor client, or the OpenTelemetry exporter not configured.
fix
Call InstructorInstrumentor().instrument() before any instructor usage, and configure an OTLP exporter (e.g., phoenix).
Upgrade
Version history
0.1.17latest on PyPI · released May 18, 2026
Audit
Dependencies
instructorrequiredInstruments the instructor library
openinference-instrumentationoptionalCore OpenInference instrumentation package
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
2
Amazon
1
Resources
openinference-instrumentation-instructor — pip install openinference-instrumentation-instructor · libregistry