Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ version_files = [
"packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/version.py",
"packages/opentelemetry-instrumentation-groq/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/version.py",
"packages/opentelemetry-instrumentation-deepseek/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-deepseek/opentelemetry/instrumentation/deepseek/version.py",
"packages/opentelemetry-instrumentation-agno/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-agno/opentelemetry/instrumentation/agno/version.py",
"packages/opentelemetry-instrumentation-alephalpha/pyproject.toml:^version",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
53 changes: 53 additions & 0 deletions packages/opentelemetry-instrumentation-deepseek/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# OpenTelemetry DeepSeek Instrumentation

<a href="https://pypi.org/project/opentelemetry-instrumentation-deepseek/">
<img src="https://badge.fury.io/py/opentelemetry-instrumentation-deepseek.svg" alt="PyPI version">
</a>

This library allows tracing prompts and completions sent to [DeepSeek](https://platform.deepseek.com/) using the official [OpenAI SDK](https://github.com/openai/openai-python), since DeepSeek's API is OpenAI-compatible.

## Installation

```bash
pip install opentelemetry-instrumentation-deepseek
```

## Example usage

```python
from opentelemetry.instrumentation.deepseek import DeepSeekInstrumentor

DeepSeekInstrumentor().instrument()
```

This instrumentor patches `openai.resources.chat.completions.Completions.create` and `AsyncCompletions.create`, but only creates spans for requests made through a client configured with a DeepSeek `base_url`. Regular OpenAI clients are left untouched, so this instrumentation can be safely enabled alongside [opentelemetry-instrumentation-openai](https://pypi.org/project/opentelemetry-instrumentation-openai/).

```python
from openai import OpenAI

client = OpenAI(
api_key="<DEEPSEEK_API_KEY>",
base_url="https://api.deepseek.com",
)

response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello!"}],
)
```

## DeepSeek-R1 reasoning content

The `deepseek-reasoner` model (DeepSeek-R1) returns its chain-of-thought in a `reasoning_content` field on the response message, in addition to the final `content`. This instrumentation captures `reasoning_content` as the `gen_ai.deepseek.reasoning_content` span attribute, for both streaming and non-streaming responses.

## Privacy

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

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.

To disable logging, set the `TRACELOOP_TRACE_CONTENT` environment variable to `false`.

```bash
TRACELOOP_TRACE_CONTENT=false
```
Loading