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

1import os
2
3from qdrant_client import QdrantClient, models
4from respan import Respan, workflow
5from respan_instrumentation_qdrant import QdrantInstrumentor
6
7respan = Respan(
8 api_key=os.environ["RESPAN_API_KEY"],
9 instrumentations=[QdrantInstrumentor()],
10)
11
12
13@workflow(name="qdrant_queries_and_filters_workflow")
14def run_qdrant_query():
15 client = QdrantClient(location=":memory:")
16 client.create_collection(
17 collection_name="documents",
18 vectors_config=models.VectorParams(
19 size=4,
20 distance=models.Distance.COSINE,
21 ),
22 )
23 client.upsert(
24 collection_name="documents",
25 points=[
26 models.PointStruct(
27 id=1,
28 vector=[0.9, 0.1, 0.0, 0.0],
29 payload={"topic": "observability"},
30 ),
31 models.PointStruct(
32 id=2,
33 vector=[0.2, 0.8, 0.0, 0.0],
34 payload={"topic": "search"},
35 ),
36 ],
37 )
38
39 return client.query_points(
40 collection_name="documents",
41 query=[0.85, 0.15, 0.0, 0.0],
42 limit=2,
43 with_payload=True,
44 with_vectors=True,
45 )
46
47
48result = run_qdrant_query()
49for point in result.points:
50 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:

1from respan import Respan
2from respan_instrumentation_qdrant import QdrantInstrumentor
3
4respan = Respan(
5 instrumentations=[QdrantInstrumentor(capture_content=False)],
6)

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

1from respan import Respan
2from respan_instrumentation_qdrant import QdrantInstrumentor
3
4respan = Respan(
5 instrumentations=[QdrantInstrumentor()],
6 customer_identifier="user_123",
7 metadata={"service": "qdrant-rag-api", "version": "1.0.0"},
8)

With propagate_attributes

1from respan import propagate_attributes
2
3
4def search(client, user_id: str, query_vector: list[float]):
5 with propagate_attributes(
6 customer_identifier=user_id,
7 thread_identifier="qdrant_thread",
8 metadata={"collection": "documents", "plan": "pro"},
9 ):
10 return client.query_points(
11 collection_name="documents",
12 query=query_vector,
13 limit=2,
14 )
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related operations into a thread.
metadatadictCustom key-value pairs merged with default metadata.