> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# Qdrant (tracing)

> Trace Qdrant collection, point, payload, and vector-query operations with Respan.

[Qdrant](https://qdrant.tech/) is an open-source vector similarity search engine with filtering, payload indexing, multiple distance metrics, and local or hosted deployments. The Respan-owned Qdrant instrumentation traces synchronous and asynchronous client operations as canonical task spans.

#### Set up Respan

Create an account at [platform.respan.ai](https://platform.respan.ai) and grab an [API key](https://platform.respan.ai/platform/gateway/api-keys).

Run `npx @respan/cli setup` to set up with your coding agent.

#### Example projects

* [Python examples](https://github.com/respanai/respan-example-projects/tree/main/python/tracing/qdrant)

#### Tracing

## Setup

#### Install packages

```bash
pip install respan-ai respan-instrumentation-qdrant qdrant-client
```

#### Set environment variables

```bash
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
```

`RESPAN_API_KEY` is used to export traces to Respan. Qdrant's in-memory mode keeps this quickstart independent of an external Qdrant server.

#### Initialize and run

```python
import os

from qdrant_client import QdrantClient, models
from respan import Respan, workflow
from respan_instrumentation_qdrant import QdrantInstrumentor

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    instrumentations=[QdrantInstrumentor()],
)


@workflow(name="qdrant_queries_and_filters_workflow")
def run_qdrant_query():
    client = QdrantClient(location=":memory:")
    client.create_collection(
        collection_name="documents",
        vectors_config=models.VectorParams(
            size=4,
            distance=models.Distance.COSINE,
        ),
    )
    client.upsert(
        collection_name="documents",
        points=[
            models.PointStruct(
                id=1,
                vector=[0.9, 0.1, 0.0, 0.0],
                payload={"topic": "observability"},
            ),
            models.PointStruct(
                id=2,
                vector=[0.2, 0.8, 0.0, 0.0],
                payload={"topic": "search"},
            ),
        ],
    )

    return client.query_points(
        collection_name="documents",
        query=[0.85, 0.15, 0.0, 0.0],
        limit=2,
        with_payload=True,
        with_vectors=True,
    )


result = run_qdrant_query()
for point in result.points:
    print(point.id, point.score, point.payload)

```

#### View your trace

Open the [Traces page](https://platform.respan.ai/platform/traces) and search for workflow name `qdrant_queries_and_filters_workflow`.

## Covered operations

The instrumentor covers collection lifecycle and administration, point upserts and deletes, payload and vector mutations, retrieval and scrolling, filtered and batch queries, facets, snapshots, and their asynchronous equivalents when provided by `AsyncQdrantClient`.

## Content capture

Request arguments and operation results are captured by default. Disable them when vectors, payloads, or query results should not be attached to spans:

```python
from respan import Respan
from respan_instrumentation_qdrant import QdrantInstrumentor

respan = Respan(
    instrumentations=[QdrantInstrumentor(capture_content=False)],
)
```

Operation names, status, and database attributes are still emitted when content capture is disabled.

## Configuration

| Parameter             | Type           | Default | Description                                                           |
| --------------------- | -------------- | ------- | --------------------------------------------------------------------- |
| `api_key`             | `str \| None`  | `None`  | Falls back to the `RESPAN_API_KEY` environment variable.              |
| `base_url`            | `str \| None`  | `None`  | Falls back to the `RESPAN_BASE_URL` environment variable.             |
| `instrumentations`    | `list`         | `[]`    | Plugin instrumentations to activate, such as `QdrantInstrumentor()`.  |
| `capture_content`     | `bool`         | `True`  | `QdrantInstrumentor` option that controls request and result capture. |
| `customer_identifier` | `str \| None`  | `None`  | Default customer identifier for all spans.                            |
| `metadata`            | `dict \| None` | `None`  | Default metadata attached to all spans.                               |
| `environment`         | `str \| None`  | `None`  | Environment tag, such as `"production"`.                              |

## Attributes

### In Respan()

```python
from respan import Respan
from respan_instrumentation_qdrant import QdrantInstrumentor

respan = Respan(
    instrumentations=[QdrantInstrumentor()],
    customer_identifier="user_123",
    metadata={"service": "qdrant-rag-api", "version": "1.0.0"},
)
```

### With propagate_attributes

```python
from respan import propagate_attributes


def search(client, user_id: str, query_vector: list[float]):
    with propagate_attributes(
        customer_identifier=user_id,
        thread_identifier="qdrant_thread",
        metadata={"collection": "documents", "plan": "pro"},
    ):
        return client.query_points(
            collection_name="documents",
            query=query_vector,
            limit=2,
        )
```

| Attribute             | Type   | Description                                          |
| --------------------- | ------ | ---------------------------------------------------- |
| `customer_identifier` | `str`  | Identifies the end user in Respan analytics.         |
| `thread_identifier`   | `str`  | Groups related operations into a thread.             |
| `metadata`            | `dict` | Custom key-value pairs merged with default metadata. |