Skip to content

Commit 1dc1e89

Browse files
galzilberclaude
andauthored
feat(instrumentation): Add litellm package instrumentation (#4322)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent fb292d0 commit 1dc1e89

26 files changed

Lines changed: 5594 additions & 253 deletions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# OpenTelemetry LiteLLM Instrumentation
2+
3+
<a href="https://pypi.org/project/opentelemetry-instrumentation-litellm/">
4+
<img src="https://badge.fury.io/py/opentelemetry-instrumentation-litellm.svg">
5+
</a>
6+
7+
This library allows tracing LLM prompts and completions sent with [LiteLLM](https://github.com/BerriAI/litellm). Because LiteLLM normalizes every provider's reply into an OpenAI-style `ModelResponse` — including custom providers registered via `litellm.CustomLLM` — a single set of wrappers produces consistent `gen_ai.*` spans and metrics across all back-ends.
8+
9+
## Installation
10+
11+
```bash
12+
pip install opentelemetry-instrumentation-litellm
13+
```
14+
15+
## Example usage
16+
17+
```python
18+
from opentelemetry.instrumentation.litellm import LiteLLMInstrumentor
19+
20+
LiteLLMInstrumentor().instrument()
21+
```
22+
23+
## Privacy
24+
25+
**By default, this instrumentation logs prompts, completions, and embeddings to span attributes**. This gives you a clear visibility into how your LLM application is working, and can make it easy to debug and evaluate the quality of the outputs.
26+
27+
However, you may want to disable this logging for privacy reasons, as they may contain highly sensitive data from your users. You may also simply want to reduce the size of your traces.
28+
29+
To disable logging, set the `TRACELOOP_TRACE_CONTENT` environment variable to `false`.
30+
31+
```bash
32+
TRACELOOP_TRACE_CONTENT=false
33+
```

0 commit comments

Comments
 (0)