Vector databases
cetra reads the spans of your Chroma, Qdrant and Milvus calls through OpenLIT or OpenLLMetry, and the same instrumentors cover Pinecone and Weaviate. A read is a retriever span; a write is a plain span.
Install
Section titled “Install”Install the client of your database and one of the two instrumentors. The fixtures were captured with chromadb 1.5.9, qdrant-client 1.20.0 and pymilvus 3.0.3.
pip install openlit chromadb qdrant-client "pymilvus[milvus_lite]"pip install opentelemetry-instrumentation-chromadb==0.63.1 opentelemetry-instrumentation-qdrant==0.63.1 opentelemetry-instrumentation-milvus==0.60.0 chromadb qdrant-client "pymilvus[milvus_lite]"opentelemetry-instrumentation-milvus 0.63.1 does not install: it requires a package that is not on PyPI. 0.60.0 is the newest version that installs.
Set up through OpenLIT
Section titled “Set up through OpenLIT”Call openlit.init once, then use the clients. See OpenLIT for the other init arguments.
import os
import chromadbimport openlitfrom qdrant_client import QdrantClientfrom qdrant_client.models import Distance, PointStruct, VectorParams
openlit.init( otlp_endpoint=os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"], otlp_headers=f"Authorization=Bearer {os.environ['CETRA_API_KEY']}", disable_metrics=True, disabled_instrumentors=["httpx", "requests", "urllib3", "aiohttp"],)
chroma = chromadb.EphemeralClient()collection = chroma.get_or_create_collection("docs")collection.add(ids=["a"], documents=["sunny"], embeddings=[[0.1, 0.2]])collection.query(query_embeddings=[[0.15, 0.25]], n_results=1)
qdrant = QdrantClient(":memory:")qdrant.create_collection("docs", vectors_config=VectorParams(size=2, distance=Distance.COSINE))qdrant.upsert("docs", points=[PointStruct(id=1, vector=[0.1, 0.2], payload={"text": "sunny"})])qdrant.query_points("docs", query=[0.15, 0.25], limit=1)Set CETRA_API_KEY to your sk-cetra-… API key. See Send OpenTelemetry.
Set up through OpenLLMetry
Section titled “Set up through OpenLLMetry”Instrument each client, then use it. The instrumentors export through the tracer provider you pass them.
import chromadbfrom opentelemetry import tracefrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporterfrom opentelemetry.instrumentation.chromadb import ChromaInstrumentorfrom opentelemetry.instrumentation.qdrant import QdrantInstrumentorfrom opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessor
provider = TracerProvider()provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))trace.set_tracer_provider(provider)ChromaInstrumentor().instrument(tracer_provider=provider)QdrantInstrumentor().instrument(tracer_provider=provider)
chroma = chromadb.EphemeralClient()collection = chroma.get_or_create_collection("docs")collection.add(ids=["a"], documents=["sunny"], embeddings=[[0.1, 0.2]])collection.query(query_embeddings=[[0.15, 0.25]], n_results=1)provider.force_flush()Set OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS as on Send OpenTelemetry.
What you get
Section titled “What you get”Each database operation is one span, and each span is a trace of its own:
- a
retrieverspan for each read: a query, search, get, fetch or scroll; - a plain
spanfor each write: an insert, upsert, delete or collection creation.
Which reads count follows the instrumentation:
- OpenLIT marks every vector span with the operation
vectordb, anddb.operation.namedecides:get,queryorsearchis aretriever(Chroma writes them in caps), and anything else is aspan. - cetra reads no operation attribute from OpenLLMetry’s instrumentors, and the span name decides, because Qdrant and Pinecone write none:
chroma.query,chroma.get,qdrant.query_points,qdrant.search,qdrant.scroll,milvus.search,milvus.queryandmilvus.getareretrievers, and so arepinecone.query,pinecone.fetchand the Weaviate query names below. Every other name is aspan.
The spans carry the counts and summaries the instrumentors write, such as the number of vectors written and the top k. No documents, no vectors and no results reach the input or output fields. OpenLLMetry writes each result as a span event, which cetra keeps on the span.
Pinecone and Weaviate
Section titled “Pinecone and Weaviate”These two sections are setup only: the repository holds no capture of them.
- Pinecone: OpenLLMetry’s instrumentor supports
pineconebelow 9 only. With Pinecone 10 it logs one line and instruments nothing, and OpenLIT’s Pinecone target fails to import on Pinecone 10. On a supported version,pinecone.queryandpinecone.fetchareretrievers and the writes arespans, as for the other databases. - Weaviate: OpenLLMetry’s instrumentor writes one span per operation, named after the method, such as
db.weaviate.collections.data.insert. The query names, startingdb.weaviate.collections.query.ordb.weaviate.gql.query., areretrievers; the writes arespans.
Limits
Section titled “Limits”- Reads are retrievers and writes are plain spans. An operation your app uses as a read keeps the kind its name gives it.
- OpenLIT’s Milvus
DELETEspan is an error span although the delete worked: OpenLIT’s wrapper fails reading the response. The span keeps the error status. - OpenLIT reads the collection name from keyword arguments only. Chroma shows the collection’s name; Qdrant and Milvus calls that pass it positionally show
unknownin the span name and indb.collection.name. - No span carries documents, vectors or results in the fields cetra fills.
- The fixtures were captured with
openlit1.45.0 and OpenLLMetry’sopentelemetry-instrumentation-chromadband-qdrant0.63.1 and-milvus0.60.0, on in-memory databases (Chroma and Qdrant) and a Milvus Lite file. - Pinecone and Weaviate were not captured. Their rules above are checked by unit tests only.
- If a field is missing, look at the span’s Attributes tab and compare it with Span attributes.
- OpenLIT: the instrumentation behind the OpenLIT route.
- OpenLLMetry: the instrumentation behind the OpenLLMetry route.
- Traces: read the trace as a tree and a timeline.