Qdrant (tracing)

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

Create an account at platform.respan.ai and grab an API key.

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

Setup

1

Install packages

pip install respan-ai respan-instrumentation-qdrant qdrant-client
2

Set environment variables

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.

3

Initialize and run

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)
4

View your trace

Open the Traces page 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:

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

ParameterTypeDefaultDescription
api_keystr | NoneNoneFalls back to the RESPAN_API_KEY environment variable.
base_urlstr | NoneNoneFalls back to the RESPAN_BASE_URL environment variable.
instrumentationslist[]Plugin instrumentations to activate, such as QdrantInstrumentor().
capture_contentboolTrueQdrantInstrumentor option that controls request and result capture.
customer_identifierstr | NoneNoneDefault customer identifier for all spans.
metadatadict | NoneNoneDefault metadata attached to all spans.
environmentstr | NoneNoneEnvironment tag, such as "production".

Attributes

In Respan()

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

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,
)
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related operations into a thread.
metadatadictCustom key-value pairs merged with default metadata.