{"id":2635,"library":"opentelemetry-instrumentation-lancedb","title":"OpenTelemetry Lancedb Instrumentation","description":"This library provides OpenTelemetry instrumentation for LanceDB, allowing tracing of client-side calls to the LanceDB vector database. It is part of the OpenLLMetry project, which extends OpenTelemetry for LLM applications. The library maintains a rapid release cadence, with multiple updates per month to keep pace with semantic convention changes and library updates.","status":"active","version":"0.58.0","language":"en","source_language":"en","source_url":"https://github.com/traceloop/openllmetry/tree/main/packages/opentelemetry-instrumentation-lancedb","tags":["opentelemetry","instrumentation","lancedb","vector-database","llm-observability","tracing","ai"],"install":[{"cmd":"pip install opentelemetry-instrumentation-lancedb lancedb opentelemetry-sdk","lang":"bash","label":"Install library and core OpenTelemetry SDK"}],"dependencies":[{"reason":"Peer dependency: the library instruments LanceDB.","package":"lancedb","optional":false},{"reason":"Core OpenTelemetry API for defining and creating telemetry data.","package":"opentelemetry-api","optional":false},{"reason":"Core OpenTelemetry SDK for processing and exporting telemetry data.","package":"opentelemetry-sdk","optional":false},{"reason":"Base package for OpenTelemetry Python instrumentations.","package":"opentelemetry-instrumentation","optional":false},{"reason":"Provides standard OpenTelemetry semantic conventions.","package":"opentelemetry-semantic-conventions","optional":false},{"reason":"Provides OpenTelemetry semantic conventions for AI/ML/LLM applications, used by OpenLLMetry.","package":"opentelemetry-semantic-conventions-ai","optional":false}],"imports":[{"symbol":"LancedbInstrumentation","correct":"from opentelemetry.instrumentation.lancedb import LancedbInstrumentation"}],"quickstart":{"code":"import lancedb\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.resources import Resource\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\nfrom opentelemetry.instrumentation.lancedb import LancedbInstrumentation\n\n# 1. Setup OpenTelemetry Tracer Provider and Exporter\nresource = Resource.create({\"service.name\": \"lancedb-app\"})\ntracer_provider = TracerProvider(resource=resource)\nspan_processor = SimpleSpanProcessor(ConsoleSpanExporter())\ntracer_provider.add_span_processor(span_processor)\ntrace.set_tracer_provider(tracer_provider)\n\n# 2. Initialize LanceDB Instrumentation\nLancedbInstrumentation().instrument()\n\n# 3. Use LanceDB (will now be instrumented)\nprint(\"\\n--- Performing LanceDB operations ---\")\nuri = \".lancedb_test\"\ndb = lancedb.connect(uri)\n\n# Create a table\ndata = [\n    {\"vector\": [0.1, 0.2], \"text\": \"hello\"},\n    {\"vector\": [0.3, 0.4], \"text\": \"world\"}\n]\ntable = db.create_table(\"my_table\", data=data, mode=\"overwrite\")\n\n# Add more data\ntable.add([{\"vector\": [0.5, 0.6], \"text\": \"opentelemetry\"}])\n\n# Search data\nresults = table.search([0.2, 0.3]).limit(1).to_list()\nprint(f\"Search results: {results}\")\n\n# Clean up\ndb.drop_table(\"my_table\")\nprint(\"--- LanceDB operations complete ---\")","lang":"python","description":"This example demonstrates how to set up basic OpenTelemetry tracing with a console exporter and then instrument LanceDB. Operations like connecting, creating tables, adding data, and searching will generate traces printed to the console."},"warnings":[{"fix":"Review the latest OpenTelemetry GenAI Semantic Conventions and OpenLLMetry documentation for updated attribute names. Adapt your monitoring and analysis tools accordingly after upgrading the instrumentation library.","message":"The OpenLLMetry project, which includes this instrumentation, frequently updates its semantic conventions, especially for GenAI attributes. Existing dashboards or analytical queries relying on specific span attribute names or structures related to LLM/vector DB operations may break or show incorrect data after updates.","severity":"breaking","affected_versions":"All versions, as conventions evolve rapidly (e.g., v0.53.4, v0.54.0, v0.55.0, v0.57.0, v0.58.0)."},{"fix":"Ensure you explicitly configure an OpenTelemetry `TracerProvider` and register a `SpanProcessor` with an appropriate `SpanExporter` (e.g., `ConsoleSpanExporter`, `OTLPSpanExporter`) before initializing the `LancedbInstrumentation`.","message":"This instrumentation library only adds hooks to LanceDB. For traces to be generated and exported, a full OpenTelemetry SDK setup (TracerProvider, SpanProcessor, and SpanExporter) must be configured in your application. Without this, no telemetry will be collected or visible.","severity":"gotcha","affected_versions":"All versions."},{"fix":"Install and instrument all relevant libraries in your LLM application stack (e.g., `opentelemetry-instrumentation-openai`, `opentelemetry-instrumentation-langchain`) to ensure complete observability.","message":"This instrumentation library focuses solely on LanceDB. If you are using other LLM frameworks (e.g., OpenAI, LangChain, LlamaIndex) in conjunction with LanceDB, you will need to install and instrument those libraries separately to get comprehensive end-to-end traces for your LLM application.","severity":"gotcha","affected_versions":"All versions."}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}