LanceDB

LanceDB is a serverless vector database built on the Lance columnar format. It supports embedded (in-process) and cloud deployments, with automatic versioning, fast retrieval, and native integration with ML frameworks. Respan gives you full observability over every table operation, vector search, and filter query.

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 opentelemetry-instrumentation-lancedb lancedb
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

RESPAN_API_KEY is used to export traces to Respan.

3

Initialize and run

1import lancedb
2from respan import Respan
3from opentelemetry.instrumentation.lancedb import LanceInstrumentor
4
5respan = Respan(instrumentations=[LanceInstrumentor()])
6
7db = lancedb.connect("/tmp/lancedb")
8
9data = [
10 {"text": "Respan provides AI observability.", "vector": [0.1, 0.2, 0.3, 0.4]},
11 {"text": "Vector databases enable semantic search.", "vector": [0.5, 0.6, 0.7, 0.8]},
12 {"text": "LanceDB uses the Lance format.", "vector": [0.2, 0.3, 0.4, 0.5]},
13]
14table = db.create_table("documents", data, mode="overwrite")
15
16results = table.search([0.1, 0.2, 0.3, 0.4]).limit(2).to_list()
17for result in results:
18 print(result["text"], result["_distance"])
19
20respan.flush()
4

View your trace

Open the Traces page to see your LanceDB operation spans with table operations, vector searches, and filters.

Configuration

ParameterTypeDefaultDescription
api_keystr | NoneNoneFalls back to RESPAN_API_KEY env var.
base_urlstr | NoneNoneFalls back to RESPAN_BASE_URL env var.
instrumentationslist[]Plugin instrumentations to activate (e.g. LanceInstrumentor()).
customer_identifierstr | NoneNoneDefault customer identifier for all spans.
metadatadict | NoneNoneDefault metadata attached to all spans.
environmentstr | NoneNoneEnvironment tag (e.g. "production").

Attributes

In Respan()

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

With propagate_attributes

1from respan import Respan, propagate_attributes
2from opentelemetry.instrumentation.lancedb import LanceInstrumentor
3
4respan = Respan(instrumentations=[LanceInstrumentor()])
5
6def search(user_id: str, query_vector):
7 with propagate_attributes(
8 customer_identifier=user_id,
9 thread_identifier="conv_abc_123",
10 metadata={"plan": "pro"},
11 ):
12 return table.search(query_vector).limit(2).to_list()
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related messages into a conversation.
metadatadictCustom key-value pairs. Merged with default metadata.