Python · Instrumentation
openinference-instrumentation-litellm
OpenInference liteLLM Instrumentation
- Module
openinference.instrumentation.litellm- Version
- 0.1.58
- Python
- >=3.10, <3.15
Install
pip install openinference-instrumentation-litellmUsage
Instrument once, at startup, before the library is used. The LiteLLMInstrumentor reference below lists the options.
from opentelemetry.sdk.trace import TracerProvider
from openinference.instrumentation import TraceConfig
from openinference.instrumentation.litellm import LiteLLMInstrumentor
tracer_provider = TracerProvider()
# ...add a span processor that exports to Phoenix or any OTLP backend.
LiteLLMInstrumentor().instrument(
tracer_provider=tracer_provider,
config=TraceConfig(hide_inputs=True), # optional
)openinference.instrumentation.litellm
is_iterable_of
functionSource ↗def is_iterable_of(lst: Iterable[object], tp: T) -> boolLiteLLMInstrumentor
classSource ↗class LiteLLMInstrumentor(BaseInstrumentor)Attributes
| Name | Type and value |
|---|---|
original_litellm_funcs | Dict[str, Callable[..., Any]] = {} |
original_anthropic_funcs | Dict[str, Callable[..., Any]] = {} |
original_anthropic_signatures | Dict[str, inspect.Signature] = {} |
instrument
methoddef instrument(
*,
tracer_provider: Optional[TracerProvider] = None,
config: Optional[TraceConfig] = None,
skip_dep_check: bool = False,
) -> NoneStart tracing the library: patch it so its calls make OpenInference spans. Calling it again does nothing. Inherited from OpenTelemetry’s BaseInstrumentor.
Parameters
| Name | Description |
|---|---|
tracer_provider | The tracer provider the spans are made with. Defaults to the global one, |
config | What the spans record: hide inputs, outputs or messages, or limit image sizes. Defaults to |
skip_dep_check | Instrument even if the installed version of the library is outside the supported range. |
uninstrument
methoddef uninstrument() -> NoneStop tracing: undo the patches instrument() made. Inherited from OpenTelemetry’s BaseInstrumentor.
instrumentation_dependencies
methodSource ↗def instrumentation_dependencies() -> Collection[str]