Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

fix: Add version-aware Qdrant instrumentation for v1.16.0+ compatibility (#981)

Vedant Madane7368f9e0f9c1
diff --git a/assets/pricing.json b/assets/pricing.json
index 22b078a5..1880c1bb 100644
--- a/assets/pricing.json
+++ b/assets/pricing.json
@@ -513,6 +513,26 @@
"promptPrice": 0.0005,
"completionPrice": 0.0015
},
+ "grok-2": {
+ "promptPrice": 0.0005,
+ "completionPrice": 0.0015
+ },
+ "grok-3": {
+ "promptPrice": 0.0005,
+ "completionPrice": 0.0015
+ },
+ "grok-3-mini": {
+ "promptPrice": 0.0001,
+ "completionPrice": 0.0003
+ },
+ "grok-4": {
+ "promptPrice": 0.002,
+ "completionPrice": 0.008
+ },
+ "grok-4-fast": {
+ "promptPrice": 0.0005,
+ "completionPrice": 0.0015
+ },
"grok-vision-beta": {
"promptPrice": 0.0005,
"completionPrice": 0.0015
diff --git a/examples/test_qdrant_compatibility.py b/examples/test_qdrant_compatibility.py
new file mode 100644
index 00000000..646e86da
--- /dev/null
+++ b/examples/test_qdrant_compatibility.py
@@ -0,0 +1,63 @@
+"""
+Test script to reproduce Issue #971 - Qdrant instrumentation failure with qdrant-client >= 1.16.0
+"""
+import sys
+
+print("=" * 60)
+print("Testing Qdrant Instrumentation Issue #971")
+print("=" * 60)
+
+# Check qdrant-client version
+try:
+ import importlib.metadata
+ qdrant_version = importlib.metadata.version("qdrant-client")
+ print(f"✓ qdrant-client version: {qdrant_version}")
+except Exception as e:
+ print(f"✗ Cannot detect qdrant-client version: {e}")
+ sys.exit(1)
+
+# Check if deprecated methods exist
+try:
+ from qdrant_client import QdrantClient
+ deprecated = ["search", "search_groups", "recommend"]
+ new_methods = ["query_points", "query_points_groups", "query_batch_points"]
+
+ print(f"\nDeprecated methods availability:")
+ for method in deprecated:
+ has_method = hasattr(QdrantClient, method)
+ status = "✓" if has_method else "✗"
+ print(f" {status} {method}: {has_method}")
+
+ print(f"\nNew methods availability:")
+ for method in new_methods:
+ has_method = hasattr(QdrantClient, method)
+ status = "✓" if has_method else "✗"
+ print(f" {status} {method}: {has_method}")
+
+except Exception as e:
+ print(f"✗ Error checking QdrantClient methods: {e}")
+ sys.exit(1)
+
+# Try to initialize OpenLIT
+print(f"\n{'=' * 60}")
+print("Attempting to initialize OpenLIT instrumentation...")
+print("=" * 60)
+
+try:
+ import openlit
+ openlit.init(
+ otlp_endpoint="http://localhost:4318",
+ collect_gpu_stats=False,
+ disable_batch=True
+ )
+ print("✓ OpenLIT instrumentation initialized successfully!")
+
+except Exception as e:
+ print(f"✗ OpenLIT instrumentation FAILED: {e}")
+ import traceback
+ traceback.print_exc()
+ sys.exit(1)
+
+print(f"\n{'=' * 60}")
+print("Test completed successfully!")
+print("=" * 60)
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/__init__.py b/sdk/python/src/openlit/instrumentation/qdrant/__init__.py
index c432883b..90fe8ce7 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/__init__.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/__init__.py
@@ -13,6 +13,7 @@ from openlit.instrumentation.qdrant.async_qdrant import async_general_wrap
_instruments = ("qdrant-client >= 1.16.0",)
# Operations to wrap for both sync and async clients
+# Note: Some methods are version-dependent and will be filtered at runtime
QDRANT_OPERATIONS = [
("create_collection", "qdrant.create_collection"),
("delete_collection", "qdrant.delete_collection"),
@@ -29,10 +30,17 @@ QDRANT_OPERATIONS = [
("delete", "qdrant.delete"),
("retrieve", "qdrant.retrieve"),
("scroll", "qdrant.scroll"),
+ # Deprecated in v1.13.0, removed in v1.16.0 (replaced by query_points)
+ ("search", "qdrant.search"),
+ # Deprecated in v1.13.0, removed in v1.16.0 (replaced by query_points_groups)
+ ("search_groups", "qdrant.search_groups"),
+ # Deprecated in v1.13.0, removed in v1.16.0 (replaced by query_batch_points)
+ ("recommend", "qdrant.recommend"),
("create_payload_index", "qdrant.create_payload_index"),
+ # New methods added in v1.13.0+
("query_points", "qdrant.query_points"),
- ("query_batch_points", "qdrant.query_batch_points"),
("query_points_groups", "qdrant.query_points_groups"),
+ ("query_batch_points", "qdrant.query_batch_points"),
]
@@ -54,8 +62,16 @@ class QdrantInstrumentor(BaseInstrumentor):
metrics = kwargs.get("metrics_dict")
disable_metrics = kwargs.get("disable_metrics")
- # Wrap sync operations
+ # Import QdrantClient to check method availability
+ # pylint: disable=import-outside-toplevel
+ from qdrant_client import QdrantClient, AsyncQdrantClient
+
+ # Wrap sync operations (only if method exists in this version)
for method_name, endpoint in QDRANT_OPERATIONS:
+ # Check if method exists on QdrantClient before attempting to wrap
+ if not hasattr(QdrantClient, method_name):
+ continue
+
wrap_function_wrapper(
"qdrant_client",
f"QdrantClient.{method_name}",
@@ -72,8 +88,12 @@ class QdrantInstrumentor(BaseInstrumentor):
),
)
- # Wrap async operations
+ # Wrap async operations (only if method exists in this version)
for method_name, endpoint in QDRANT_OPERATIONS:
+ # Check if method exists on AsyncQdrantClient before attempting to wrap
+ if not hasattr(AsyncQdrantClient, method_name):
+ continue
+
wrap_function_wrapper(
"qdrant_client",
f"AsyncQdrantClient.{method_name}",
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py b/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py
index 2915fdaf..0623997f 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/async_qdrant.py
@@ -28,6 +28,7 @@ def async_general_wrap(
"""
Generates a telemetry wrapper for Pinecone function calls.
"""
+ # pylint: disable=too-many-arguments, too-many-positional-arguments, protected-access
async def wrapper(wrapped, instance, args, kwargs):
"""
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py b/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py
index 94c08868..68485684 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/qdrant.py
@@ -28,6 +28,7 @@ def general_wrap(
"""
Generates a telemetry wrapper for Pinecone function calls.
"""
+ # pylint: disable=too-many-arguments, too-many-positional-arguments, protected-access
def wrapper(wrapped, instance, args, kwargs):
"""
diff --git a/sdk/python/src/openlit/instrumentation/qdrant/utils.py b/sdk/python/src/openlit/instrumentation/qdrant/utils.py
index 688a5dd0..bb685765 100644
--- a/sdk/python/src/openlit/instrumentation/qdrant/utils.py
+++ b/sdk/python/src/openlit/instrumentation/qdrant/utils.py
@@ -28,6 +28,11 @@ DB_OPERATION_MAP = {
"qdrant.clear_payload": SemanticConvention.DB_OPERATION_DELETE,
"qdrant.retrieve": SemanticConvention.DB_OPERATION_GET,
"qdrant.scroll": SemanticConvention.DB_OPERATION_GET,
+ # Deprecated in v1.13.0, removed in v1.16.0
+ "qdrant.search": SemanticConvention.DB_OPERATION_GET,
+ "qdrant.search_groups": SemanticConvention.DB_OPERATION_GET,
+ "qdrant.recommend": SemanticConvention.DB_OPERATION_GET,
+ # New methods (v1.13.0+)
"qdrant.query_points": SemanticConvention.DB_OPERATION_QUERY,
"qdrant.query_batch_points": SemanticConvention.DB_OPERATION_QUERY,
"qdrant.query_points_groups": SemanticConvention.DB_OPERATION_QUERY,
@@ -71,7 +76,7 @@ def set_server_address_and_port(instance):
server_address = parsed.hostname
if parsed.port:
server_port = parsed.port
- except Exception:
+ except Exception: # pylint: disable=broad-exception-caught
pass
# Also try direct port from init_options if URL parsing didnt work
@@ -95,6 +100,9 @@ def common_qdrant_logic(
"""
Process Qdrant request and generate telemetry.
"""
+ # pylint: disable=too-many-arguments, too-many-positional-arguments, too-many-locals
+ # pylint: disable=too-many-branches, too-many-statements, protected-access
+ # pylint: disable=unused-argument
scope._end_time = time.time()
# Set common database span attributes using helper
@@ -328,23 +336,24 @@ def common_qdrant_logic(
elif endpoint == "qdrant.query_batch_points":
requests = scope._kwargs.get("requests", [])
+ requests_count = object_count(requests)
scope._span.set_attribute(
SemanticConvention.DB_COLLECTION_NAME, collection_name
)
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(requests))
scope._span.set_attribute(
- SemanticConvention.DB_VECTOR_COUNT, object_count(requests)
+ SemanticConvention.DB_VECTOR_COUNT, requests_count
)
scope._span.set_attribute(
SemanticConvention.DB_QUERY_SUMMARY,
- f"{scope._db_operation} {collection_name} requests={object_count(requests)}",
+ f"{scope._db_operation} {collection_name} batch_requests={requests_count}",
)
elif endpoint == "qdrant.query_points_groups":
query = scope._kwargs.get("query", {})
- group_by = scope._kwargs.get("group_by", "")
+ group_by = scope._kwargs.get("group_by", "unknown")
limit = scope._kwargs.get("limit", 10)
group_size = scope._kwargs.get("group_size", 3)
@@ -415,6 +424,8 @@ def process_qdrant_response(
"""
Process Qdrant response and generate telemetry.
"""
+ # pylint: disable=too-many-arguments, too-many-positional-arguments, too-many-locals, protected-access
+ # pylint: disable=unused-argument
# Create scope object
scope = type("GenericScope", (), {})()
scope._span = span
diff --git a/sdk/python/src/openlit/otel/events.py b/sdk/python/src/openlit/otel/events.py
index 30a761c3..16c36a28 100644
--- a/sdk/python/src/openlit/otel/events.py
+++ b/sdk/python/src/openlit/otel/events.py
@@ -9,15 +9,16 @@ from opentelemetry.sdk.resources import (
SERVICE_NAME,
TELEMETRY_SDK_NAME,
DEPLOYMENT_ENVIRONMENT,
+ Resource,
)
-from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk._events import EventLoggerProvider
+from opentelemetry.sdk._logs import LoggerProvider
from opentelemetry.sdk._logs.export import (
BatchLogRecordProcessor,
SimpleLogRecordProcessor,
+ ConsoleLogExporter,
)
-from opentelemetry.sdk._logs import LoggerProvider
-from opentelemetry.sdk._logs.export import ConsoleLogExporter
+
from openlit.__helpers import parse_exporters
# pylint: disable=ungrouped-imports
diff --git a/sdk/python/src/openlit/otel/tracing.py b/sdk/python/src/openlit/otel/tracing.py
index 80ec27e4..f0c91ffb 100644
--- a/sdk/python/src/openlit/otel/tracing.py
+++ b/sdk/python/src/openlit/otel/tracing.py
@@ -9,11 +9,14 @@ from opentelemetry.sdk.resources import (
SERVICE_NAME,
TELEMETRY_SDK_NAME,
DEPLOYMENT_ENVIRONMENT,
+ Resource,
)
-from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
-from opentelemetry.sdk.trace.export import BatchSpanProcessor, SimpleSpanProcessor
-from opentelemetry.sdk.trace.export import ConsoleSpanExporter
+from opentelemetry.sdk.trace.export import (
+ BatchSpanProcessor,
+ SimpleSpanProcessor,
+ ConsoleSpanExporter,
+)
from openlit.__helpers import parse_exporters
# pylint: disable=ungrouped-imports
diff --git a/sdk/python/tests/test_xai.py.hold b/sdk/python/tests/test_xai.py.hold
index d87b8d1e..015b57b0 100644
--- a/sdk/python/tests/test_xai.py.hold
+++ b/sdk/python/tests/test_xai.py.hold
@@ -46,7 +46,7 @@ def test_sync_xai_chat_completions():
try:
response = sync_client.chat.completions.create(
- model="grok-beta",
+ model="grok-3",
messages=[
{"role": "user", "content": "Hi"},
],
@@ -73,7 +73,7 @@ async def test_async_xai_chat_completions():
try:
response = await async_client.chat.completions.create(
- model="grok-beta",
+ model="grok-3",
messages=[
{"role": "user", "content": "Hi"},
],
diff --git a/src/client/src/lib/platform/openground/provider-registry.ts b/src/client/src/lib/platform/openground/provider-registry.ts
index 347072f4..c64e9497 100644
--- a/src/client/src/lib/platform/openground/provider-registry.ts
+++ b/src/client/src/lib/platform/openground/provider-registry.ts
@@ -664,6 +664,30 @@ const PROVIDER_METADATA: Record<string, ProviderMetadata> = {
outputPricePerMToken: 15.0,
capabilities: ["streaming", "real-time"],
},
+ {
+ id: "grok-2",
+ displayName: "Grok 2",
+ contextWindow: 131072,
+ inputPricePerMToken: 5.0,
+ outputPricePerMToken: 15.0,
+ capabilities: ["streaming", "real-time"],
+ },
+ {
+ id: "grok-3",
+ displayName: "Grok 3",
+ contextWindow: 131072,
+ inputPricePerMToken: 5.0,
+ outputPricePerMToken: 15.0,
+ capabilities: ["streaming", "real-time"],
+ },
+ {
+ id: "grok-3-mini",
+ displayName: "Grok 3 Mini",
+ contextWindow: 131072,
+ inputPricePerMToken: 1.0,
+ outputPricePerMToken: 3.0,
+ capabilities: ["streaming", "real-time"],
+ },
{
id: "grok-vision-beta",
displayName: "Grok Vision Beta",