Milvus

Trace Milvus vector database operations with Respan.
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page

Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://mcp.respan.ai/mcp/docs"
5 }
6 }
7}

What is Milvus?

Milvus is an open-source vector database built for scalable similarity search. It supports billion-scale vector data, multiple index types (IVF, HNSW, DiskANN), and hybrid search combining vector similarity with scalar filtering.

Setup

1

Install packages

$pip install respan-ai opentelemetry-instrumentation-milvus pymilvus
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.respan.ai/api"
$export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer $RESPAN_API_KEY"
3

Run a traced example

1from respan import Respan
2
3# Auto-discover and activate all installed instrumentors
4respan = Respan(is_auto_instrument=True)
5
6from pymilvus import MilvusClient
7
8# Connect to Milvus
9client = MilvusClient(uri="http://localhost:19530")
10
11# Create a collection
12client.create_collection(
13 collection_name="documents",
14 dimension=4,
15)
16
17# Insert vectors
18data = [
19 {"id": 1, "vector": [0.1, 0.2, 0.3, 0.4], "text": "AI observability with Respan"},
20 {"id": 2, "vector": [0.5, 0.6, 0.7, 0.8], "text": "Vector similarity search"},
21 {"id": 3, "vector": [0.2, 0.3, 0.4, 0.5], "text": "Scalable vector indexing"},
22]
23client.insert(collection_name="documents", data=data)
24
25# Search for similar vectors
26results = client.search(
27 collection_name="documents",
28 data=[[0.1, 0.2, 0.3, 0.4]],
29 limit=2,
30 output_fields=["text"],
31)
32for hits in results:
33 for hit in hits:
34 print(f"{hit['entity']['text']} (distance: {hit['distance']:.4f})")
35
36respan.flush()
4

View your trace

Open the Traces page to see your Milvus operation spans.

Always call respan.flush() before your process exits. Without it, pending spans may be lost.

What gets traced

  • Collection and partition management
  • Vector insert and delete operations
  • Similarity search with configurable metrics
  • Index building and loading
  • Query parameters and filter expressions
  • Operation latency

Learn more