Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.
TypeScript agent-harnessagent-harness-engineeringai-engineeringai-observabilityamd-gpuclaude-codeclickhousecodexcoding-agentcoding-agentscursorgenaigpu-monitoringllm-observabilityllmopsnvidia-smiobservabilityopen-sourceopenaiopentelemetry
[Feat]: Refactor Pinecone OpenTelemetry Monitoring Instrumentation (#798)
Patcher0c7e81059922
diff --git a/contributors/README.md b/contributors/README.mdnew file mode 100644index 00000000..bbed8bb7--- /dev/null+++ b/contributors/README.md@@ -0,0 +1,50 @@+# Contributors Guide++This directory contains comprehensive guides for contributing to the OpenLIT project. These guides provide detailed instructions, patterns, and best practices for extending OpenLIT's capabilities.++## Available Guides++### π [Vector Database Instrumentation Guide](./vector-database-instrumentation-guide.md)+Complete guide for adding new vector database instrumentations to OpenLIT, including:+- File structure and organization+- Code patterns and conventions+- Implementation steps+- Testing guidelines+- Integration requirements++## Contributing Guidelines++When contributing to OpenLIT, please:++1. **Follow the established patterns** - Use the guides in this directory to maintain consistency+2. **Test thoroughly** - Include both sync and async tests with proper error handling+3. **Document changes** - Update guides if you introduce new patterns or conventions+4. **Review existing implementations** - Use existing instrumentations as reference examples++## Code Standards++All contributions must follow:+- **Consistent file structure** - 4-file pattern for instrumentations+- **Proper naming conventions** - snake_case for functions/variables, PascalCase for classes+- **Code style guidelines** - Double quotes, 4-space indentation, proper import order+- **Error handling** - Graceful handling of rate limits and API errors+- **OpenTelemetry compliance** - Proper span management and semantic conventions++## Getting Help++If you have questions about contributing:+1. Check the relevant guide in this directory+2. Review existing implementations for reference+3. Open an issue for discussion if needed++## Future Guides++This directory will be expanded with additional guides covering:+- LLM Provider Instrumentation+- Custom Metrics Implementation+- Testing Best Practices+- Performance Optimization++---++**Note**: These guides are living documents that evolve with the project. Please help keep them updated as patterns and conventions change.\ No newline at end of filediff --git a/contributors/adding-new-vectordb-instrumentation.md b/contributors/adding-new-vectordb-instrumentation.mdnew file mode 100644index 00000000..847537e6--- /dev/null+++ b/contributors/adding-new-vectordb-instrumentation.md@@ -0,0 +1,406 @@+# Vector Database Instrumentation Guide++This guide provides step-by-step instructions for adding a new vector database instrumentation to OpenLIT, following the established patterns and conventions.++## Table of Contents+1. [File Structure](#file-structure)+2. [Code Structure](#code-structure)+3. [Naming Conventions](#naming-conventions)+4. [Code Style Guidelines](#code-style-guidelines)+5. [Implementation Steps](#implementation-steps)+6. [Testing](#testing)+7. [Integration](#integration)++## File Structure++Every vector database instrumentation follows a consistent **4-file structure**:++```+sdk/python/src/openlit/instrumentation/{database_name}/+βββ __init__.py # Instrumentor class with dependency requirements+βββ {database_name}.py # Sync wrapper functions+βββ async_{database_name}.py # Async wrapper functions+βββ utils.py # Telemetry processing logic+```++### Example Structure (using "pinecone" as example):+```+sdk/python/src/openlit/instrumentation/pinecone/+βββ __init__.py+βββ pinecone.py+βββ async_pinecone.py+βββ utils.py+```++## Code Structure++### 1. DB_OPERATION_MAP Pattern++All vector database instrumentations use a centralized operation mapping in `utils.py`:++```python+# Operation mapping for simple span naming+DB_OPERATION_MAP = {+ "{database}.create_index": SemanticConvention.DB_OPERATION_CREATE_INDEX,+ "{database}.upsert": SemanticConvention.DB_OPERATION_UPSERT,+ "{database}.query": SemanticConvention.DB_OPERATION_QUERY,+ "{database}.search": SemanticConvention.DB_OPERATION_SEARCH,+ "{database}.fetch": SemanticConvention.DB_OPERATION_FETCH,+ "{database}.update": SemanticConvention.DB_OPERATION_UPDATE,+ "{database}.delete": SemanticConvention.DB_OPERATION_DELETE,+}+```++### 2. General Wrap Pattern++Use the **general_wrap** pattern for efficiency:++```python+def general_wrap(endpoint, version, environment, application_name, tracer,+ pricing_info, capture_message_content, metrics, disable_metrics):+ """+ Create a wrapper for {database} operations using the general wrap pattern.+ """+ def wrapper(wrapped, instance, args, kwargs):+ # CRITICAL: Suppression check+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):+ return wrapped(*args, **kwargs)++ # Extract operation from endpoint+ db_operation = DB_OPERATION_MAP.get(endpoint, "unknown")++ # Server address calculation+ server_address, server_port = set_server_address_and_port(+ instance, "default-host", default_port+ )++ # CRITICAL: Use tracer.start_as_current_span() for proper context+ with tracer.start_as_current_span(f"{db_operation} {target}") as span:+ start_time = time.time()++ try:+ response = wrapped(*args, **kwargs)++ # Process response+ process_vectordb_response(+ response, db_operation, server_address, server_port,+ environment, application_name, metrics, start_time, span,+ capture_message_content, disable_metrics, version,+ instance, args, **kwargs+ )++ return response+ except Exception as e:+ handle_exception(span, e)+ raise++ return wrapper+```++### 3. Helper Functions++Include standard helper functions in `utils.py`:++```python+def object_count(obj):+ """+ Counts length of object if it exists, else returns 0.+ """+ return len(obj) if obj else 0++def common_vectordb_logic(scope, environment, application_name,+ metrics, capture_message_content, disable_metrics, version, instance=None):+ """+ Process vector database request and generate telemetry.+ """+ # Implementation details...+```++## Naming Conventions++### 1. File Names+- Use lowercase with underscores: `{database_name}.py`+- Async files: `async_{database_name}.py`+- No hyphens, use underscores++### 2. Function Names+- Use `snake_case` consistently+- Standard function names:+ - `general_wrap`+ - `async_general_wrap`+ - `common_vectordb_logic`+ - `process_vectordb_response`++### 3. Variable Names+- Use `snake_case` for all variables+- Standard variable names:+ - `server_address`, `server_port`+ - `start_time`, `end_time`+ - `db_operation`+ - `namespace`++### 4. Class Names+- Use `PascalCase` for classes+- Instrumentor class: `{DatabaseName}Instrumentor`++## Code Style Guidelines++### 1. Quotes+- **Always use double quotes** for strings: `"example"`+- Consistent across all files++### 2. Indentation+- **4 spaces** for indentation+- No tabs++### 3. Comments+- **Triple double quotes** for docstrings:+ ```python+ def function_name():+ """+ Function description.+ """+ ```+- Single line comments use `#`++### 4. Import Order+Follow this specific order:+```python+# Standard library imports+import time++# OpenTelemetry imports+from opentelemetry.trace import Status, StatusCode+from opentelemetry import context as context_api++# OpenLIT imports+from openlit.__helpers import (+ common_db_span_attributes,+ record_db_metrics,+ handle_exception,+)+from openlit.semcov import SemanticConvention+```++### 5. Function Parameters+Standard parameter order:+```python+def function_name(version, environment, application_name, tracer,+ pricing_info, capture_message_content, metrics, disable_metrics):+```++## Implementation Steps++### Step 1: Create Directory Structure+```bash+mkdir -p sdk/python/src/openlit/instrumentation/{database_name}+```++### Step 2: Create __init__.py+```python+"""+OpenLIT {DatabaseName} Instrumentation+"""++from typing import Collection+from opentelemetry.instrumentation.instrumentor import BaseInstrumentor+from opentelemetry.instrumentation.utils import unwrap+from wrapt import wrap_function_wrapper++from openlit.instrumentation.{database_name}.{database_name} import general_wrap+from openlit.instrumentation.{database_name}.async_{database_name} import async_general_wrap++class {DatabaseName}Instrumentor(BaseInstrumentor):+ """+ OpenLIT Instrumentor for {DatabaseName}+ """++ def instrumentation_dependencies(self) -> Collection[str]:+ return ["{database-package-name}"]++ def _instrument(self, **kwargs):+ """+ Instrument {DatabaseName} operations+ """+ # Extract parameters+ version = kwargs.get("version", "1.0.0")+ environment = kwargs.get("environment", "default")+ application_name = kwargs.get("application_name", "default")+ tracer = kwargs.get("tracer")+ pricing_info = kwargs.get("pricing_info")+ capture_message_content = kwargs.get("capture_message_content", False)+ metrics = kwargs.get("metrics")+ disable_metrics = kwargs.get("disable_metrics", False)++ # Wrap functions+ wrap_function_wrapper(+ "{database_module}",+ "{Class}.{method}",+ general_wrap(+ "{database}.{operation}",+ version, environment, application_name, tracer,+ pricing_info, capture_message_content, metrics, disable_metrics+ ),+ )++ def _uninstrument(self, **kwargs):+ """+ Uninstrument {DatabaseName} operations+ """+ unwrap({database_module}.{Class}, "{method}")+```++### Step 3: Create Wrapper Files+Create both sync and async wrapper files following the general_wrap pattern.++### Step 4: Create utils.py+Include:+- `DB_OPERATION_MAP`+- `object_count` helper+- `common_vectordb_logic`+- `process_vectordb_response`++### Step 5: Operation-Specific Attributes+Handle different operations in `common_vectordb_logic`:++```python+if scope._db_operation == SemanticConvention.DB_OPERATION_CREATE_INDEX:+ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_COLLECTION_NAME, scope._kwargs.get("name", ""))++ # Vector database specific attributes+ scope._span.set_attribute(SemanticConvention.DB_COLLECTION_DIMENSION, scope._kwargs.get("dimension", -1))+ scope._span.set_attribute(SemanticConvention.DB_SEARCH_SIMILARITY_METRIC, scope._kwargs.get("metric", "cosine"))++elif scope._db_operation == SemanticConvention.DB_OPERATION_QUERY:+ namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("vector", [])++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes+ scope._span.set_attribute(SemanticConvention.DB_VECTOR_QUERY_TOP_K, scope._kwargs.get("top_k", -1))+ scope._span.set_attribute(SemanticConvention.DB_FILTER, str(scope._kwargs.get("filter", "")))+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"{scope._db_operation} {namespace} "+ f"top_k={scope._kwargs.get('top_k', -1)} "+ f"filtered={scope._kwargs.get('filter', '')} "+ f"vector={scope._kwargs.get('vector', '')}")+```++### Step 6: Usage and Metrics Extraction+Handle response processing and usage metrics:++```python+# Extract usage information if available+if scope._response.get("usage"):+ usage = scope._response["usage"]+ embed_tokens = usage.get("embed_total_tokens", 0)+ read_units = usage.get("read_units", 0)+ if embed_tokens:+ scope._span.set_attribute(SemanticConvention.DB_CLIENT_TOKEN_USAGE, embed_tokens)+ if read_units:+ scope._span.set_attribute("db.read_units", read_units)+```++## Testing++### Create Test File+Create `sdk/python/tests/test_{database_name}.py`:++```python+"""+Tests for {DatabaseName} functionality using the {DatabaseName} Python library.+"""++import pytest+import openlit+from {database_package} import {ClientClass}++# Initialize client+client = {ClientClass}()++# Initialize OpenLIT+openlit.init(environment="openlit-python-testing", application_name="openlit-python-{database}-test")++def test_sync_{database}_query():+ """+ Tests synchronous query operation.+ """+ try:+ response = client.query(+ # parameters+ )+ assert response # Add appropriate assertions++ except Exception as e:+ if "rate limit" in str(e).lower() or "429" in str(e):+ print("Rate limit exceeded:", e)+ elif "credit" in str(e).lower():+ print("Insufficient balance:", e)+ else:+ raise++async def test_async_{database}_query():+ """+ Tests asynchronous query operation.+ """+ # Similar structure for async tests+```++## Integration++### Step 1: Add to Base Instrumentation+Add to `sdk/python/src/openlit/instrumentation/__init__.py`:++```python+from openlit.instrumentation.{database_name} import {DatabaseName}Instrumentor++# Add to instrumentors list+def auto_instrument(**kwargs):+ """+ Auto-instrument supported libraries+ """+ # ... existing instrumentors ...++ # {DatabaseName} Instrumentation+ try:+ {DatabaseName}Instrumentor().instrument(**kwargs)+ except Exception as e:+ logger.warning(f"Failed to instrument {DatabaseName}: {e}")+```++### Step 2: Add Semantic Conventions+Add any new semantic conventions to `sdk/python/src/openlit/semcov/__init__.py`:++```python+# Vector Database Semantic Conventions+DB_VECTOR_QUERY_TOP_K = "db.vector.query.top_k"+DB_SEARCH_SIMILARITY_METRIC = "db.search.similarity_metric"+DB_COLLECTION_DIMENSION = "db.collection.dimension"+# ... other conventions+```++### Step 3: Update Dependencies+Add the database package to test requirements if needed.++## Key Reminders++1. **Always use `tracer.start_as_current_span()`** - Never use `tracer.start_span()` as it breaks context propagation+2. **Include suppression check** - Always check `context_api._SUPPRESS_INSTRUMENTATION_KEY`+3. **Use consistent patterns** - Follow the established 4-file structure and general_wrap pattern+4. **Handle errors gracefully** - Use `handle_exception()` for proper error handling+5. **Set server address** - Always calculate and set server_address/server_port+6. **Use helper functions** - Utilize `common_db_span_attributes()` and `record_db_metrics()`+7. **Follow naming conventions** - Use semantic convention constants, not hardcoded strings+8. **Test thoroughly** - Include both sync and async tests with error handling++## Example Implementation++For a complete reference implementation, see the Pinecone instrumentation:+- `sdk/python/src/openlit/instrumentation/pinecone/`++This guide ensures consistency across all vector database instrumentations and maintains the high quality standards of the OpenLIT project.\ No newline at end of filediff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.tomlindex 2df00ada..e3b5232d 100644--- a/sdk/python/pyproject.toml+++ b/sdk/python/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "openlit"-version = "1.34.23"+version = "1.34.24"description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"authors = ["OpenLIT"]license = "Apache-2.0"diff --git a/sdk/python/src/openlit/__helpers.py b/sdk/python/src/openlit/__helpers.pyindex a3c9bcd8..03ab9923 100644--- a/sdk/python/src/openlit/__helpers.py+++ b/sdk/python/src/openlit/__helpers.py@@ -205,11 +205,22 @@ def set_server_address_and_port(client_instance: Any,config = getattr(client_instance, 'sdk_configuration', None)base_url = getattr(config, 'server_url', None)+ if not base_url:+ # Attempt to get host from instance.config.host (used by Pinecone and other vector DBs)+ config = getattr(client_instance, 'config', None)+ base_url = getattr(config, 'host', None)+if base_url:if isinstance(base_url, str):- url = urlparse(base_url)- server_address = url.hostname or default_server_address- server_port = url.port if url.port is not None else default_server_port+ # Check if it's a full URL or just a hostname+ if base_url.startswith(('http://', 'https://')):+ url = urlparse(base_url)+ server_address = url.hostname or default_server_address+ server_port = url.port if url.port is not None else default_server_port+ else:+ # If it's just a hostname (like Pinecone's case), use it directly+ server_address = base_url+ server_port = default_server_portelse: # base_url might not be a str; handle as an object.server_address = getattr(base_url, 'host', None) or default_server_addressport_attr = getattr(base_url, 'port', None)@@ -442,3 +453,37 @@ def record_image_metrics(metrics, gen_ai_operation, gen_ai_system, server_addresmetrics["genai_client_operation_duration"].record(end_time - start_time, attributes)metrics["genai_requests"].add(1, attributes)metrics["genai_cost"].record(cost, attributes)++def common_db_span_attributes(scope, db_system, server_address, server_port,+ environment, application_name, version):+ """+ Set common span attributes for database operations.+ """++ scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")+ scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)+ scope._span.set_attribute(SemanticConvention.DB_SYSTEM_NAME, db_system)+ scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)+ scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)+ scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)+ scope._span.set_attribute(SERVICE_NAME, application_name)+ scope._span.set_attribute(SemanticConvention.DB_SDK_VERSION, version)++def record_db_metrics(metrics, db_system, server_address, server_port,+ environment, application_name, start_time, end_time):+ """+ Record database-specific metrics for the operation.+ """++ attributes = create_metrics_attributes(+ operation=SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,+ system=db_system,+ request_model=db_system,+ server_address=server_address,+ server_port=server_port,+ response_model=db_system,+ service_name=application_name,+ deployment_environment=environment,+ )+ metrics["db_requests"].add(1, attributes)+ metrics["db_client_operation_duration"].record(end_time - start_time, attributes)diff --git a/sdk/python/src/openlit/instrumentation/pinecone/__init__.py b/sdk/python/src/openlit/instrumentation/pinecone/__init__.pyindex 2575bf85..95365e42 100644--- a/sdk/python/src/openlit/instrumentation/pinecone/__init__.py+++ b/sdk/python/src/openlit/instrumentation/pinecone/__init__.py@@ -1,66 +1,174 @@-# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code"""Initializer of Auto Instrumentation of Pinecone Functions"""+from typing import Collectionimport importlib.metadatafrom opentelemetry.instrumentation.instrumentor import BaseInstrumentorfrom wrapt import wrap_function_wrapperfrom openlit.instrumentation.pinecone.pinecone import general_wrap+from openlit.instrumentation.pinecone.async_pinecone import async_general_wrap-_instruments = ("pinecone-client >= 2.2.0",)+_instruments = ("pinecone >= 7.3.0",)class PineconeInstrumentor(BaseInstrumentor):- """An instrumentor for Pinecone's client library."""+ """+ An instrumentor for Pinecone's client library.+ """def instrumentation_dependencies(self) -> Collection[str]:return _instrumentsdef _instrument(self, **kwargs):- application_name = kwargs.get("application_name")- environment = kwargs.get("environment")+ version = importlib.metadata.version("pinecone")+ environment = kwargs.get("environment", "default")+ application_name = kwargs.get("application_name", "default")tracer = kwargs.get("tracer")+ pricing_info = kwargs.get("pricing_info", {})+ capture_message_content = kwargs.get("capture_message_content", False)metrics = kwargs.get("metrics_dict")- pricing_info = kwargs.get("pricing_info")- capture_message_content = kwargs.get("capture_message_content")disable_metrics = kwargs.get("disable_metrics")- version = importlib.metadata.version("pinecone-client")+ # Sync operationswrap_function_wrapper(- "pinecone.control.pinecone",+ "pinecone.pinecone","Pinecone.create_index",- general_wrap("pinecone.create_index", version, environment, application_name,- tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ general_wrap("pinecone.create_collection", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.pinecone",+ "Pinecone.create_index_for_model",+ general_wrap("pinecone.create_collection", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),)wrap_function_wrapper(- "pinecone.data.index",+ "pinecone.db_data.index","Index.upsert",general_wrap("pinecone.upsert", version, environment, application_name,- tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index",+ "Index.upsert_records",+ general_wrap("pinecone.upsert_records", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),)wrap_function_wrapper(- "pinecone.data.index",+ "pinecone.db_data.index","Index.query",general_wrap("pinecone.query", version, environment, application_name,- tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index",+ "Index.search",+ general_wrap("pinecone.search", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),)wrap_function_wrapper(- "pinecone.data.index",+ "pinecone.db_data.index",+ "Index.fetch",+ general_wrap("pinecone.fetch", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index",+ "Index.search_records",+ general_wrap("pinecone.search_records", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index","Index.update",general_wrap("pinecone.update", version, environment, application_name,- tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),)wrap_function_wrapper(- "pinecone.data.index",+ "pinecone.db_data.index","Index.delete",general_wrap("pinecone.delete", version, environment, application_name,- tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),)+ # Async operations+ wrap_function_wrapper(+ "pinecone.pinecone_asyncio",+ "PineconeAsyncio.create_index",+ async_general_wrap("pinecone.create_index", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.pinecone_asyncio",+ "PineconeAsyncio.create_index_for_model",+ async_general_wrap("pinecone.create_index", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.upsert",+ async_general_wrap("pinecone.upsert", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.upsert_records",+ async_general_wrap("pinecone.upsert_records", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.query",+ async_general_wrap("pinecone.query", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.search",+ async_general_wrap("pinecone.search", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.fetch",+ async_general_wrap("pinecone.fetch", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.search_records",+ async_general_wrap("pinecone.search_records", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.update",+ async_general_wrap("pinecone.update", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )++ wrap_function_wrapper(+ "pinecone.db_data.index_asyncio",+ "_IndexAsyncio.delete",+ async_general_wrap("pinecone.delete", version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics),+ )- @staticmethoddef _uninstrument(self, **kwargs):passdiff --git a/sdk/python/src/openlit/instrumentation/pinecone/async_pinecone.py b/sdk/python/src/openlit/instrumentation/pinecone/async_pinecone.pynew file mode 100644index 00000000..20de9f15--- /dev/null+++ b/sdk/python/src/openlit/instrumentation/pinecone/async_pinecone.py@@ -0,0 +1,59 @@+"""+Module for monitoring Pinecone async API calls.+"""++import time+from opentelemetry.trace import SpanKind+from opentelemetry import context as context_api+from openlit.__helpers import (+ handle_exception,+ set_server_address_and_port,+)+from openlit.instrumentation.pinecone.utils import (+ process_vectordb_response,+ DB_OPERATION_MAP,+)++def async_general_wrap(gen_ai_endpoint, version, environment, application_name,+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):+ """+ Generates a telemetry wrapper for Pinecone async function calls.+ """++ async def wrapper(wrapped, instance, args, kwargs):+ """+ Wraps the Pinecone async function call.+ """++ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):+ return await wrapped(*args, **kwargs)++ # Get server address and port using the standard helper+ server_address, server_port = set_server_address_and_port(instance, "pinecone.io", 443)++ db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "unknown")+ if db_operation == "create_collection":+ namespace = kwargs.get("name") or (args[0] if args else "unknown")+ else:+ namespace = kwargs.get("namespace") or (args[0] if args else "unknown")+ span_name = f"{db_operation} {namespace}"++ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:+ try:+ start_time = time.time()+ response = await wrapped(*args, **kwargs)++ # Process response and generate telemetry+ response = process_vectordb_response(+ response, db_operation, server_address, server_port,+ environment, application_name, metrics, start_time, span,+ capture_message_content, disable_metrics, version, instance, args, **kwargs+ )++ return response++ except Exception as e:+ handle_exception(span, e)+ raise++ return wrapperdiff --git a/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py b/sdk/python/src/openlit/instrumentation/pinecone/pinecone.pyindex f647ccdd..81352da8 100644--- a/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py+++ b/sdk/python/src/openlit/instrumentation/pinecone/pinecone.py@@ -1,173 +1,59 @@-# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment"""-Module for monitoring Pinecone.+Module for monitoring Pinecone API calls."""-import logging-from opentelemetry.trace import SpanKind, Status, StatusCode-from opentelemetry.sdk.resources import SERVICE_NAME, TELEMETRY_SDK_NAME, DEPLOYMENT_ENVIRONMENT-from openlit.__helpers import handle_exception-from openlit.semcov import SemanticConvention--# Initialize logger for logging potential issues and operations-logger = logging.getLogger(__name__)--def object_count(obj):- """- Counts Length of object if it exists, Else returns None- """-- if obj:- return len(obj)-- return None+import time+from opentelemetry.trace import SpanKind+from opentelemetry import context as context_api+from openlit.__helpers import (+ handle_exception,+ set_server_address_and_port,+)+from openlit.instrumentation.pinecone.utils import (+ process_vectordb_response,+ DB_OPERATION_MAP,+)def general_wrap(gen_ai_endpoint, version, environment, application_name,- tracer, pricing_info, capture_message_content, metrics, disable_metrics):+ tracer, pricing_info, capture_message_content, metrics, disable_metrics):"""- Wraps a Pinecone operation to trace and log its execution metrics.-- This function is intended to wrap around Pinecone operations in order to- measure their execution time, log relevant information, and trace the execution- using OpenTelemetry. This helps in monitoring and debugging operations within- the Pinecone space.-- Parameters:- - pinecone_operation (str): The specific Pinecone operation being monitored.- Examples include 'create_index', 'query', 'upsert', etc.- - version (str): The version of the application interfacing with Pinecone.- - environment (str): The deployment environment, such as 'production' or 'development'.- - application_name (str): The name of the application performing the Pinecone operation.- - tracer (opentelemetry.trace.Tracer): An object used for OpenTelemetry tracing.- - pricing_info (dict): Information about pricing, not used in current implementation.- - capture_message_content (bool): A flag indicating whether the content of responses should be traced.-- Returns:- - function: A decorator function that, when applied, wraps the target function with- additional functionality for tracing and logging Pinecone operations.+ Generates a telemetry wrapper for Pinecone function calls."""def wrapper(wrapped, instance, args, kwargs):"""- Executes the wrapped Pinecone operation, adding tracing and logging.-- This inner wrapper function captures the execution of Pinecone operations,- annotating the operation with relevant metrics and tracing information, and- ensuring any exceptions are caught and logged appropriately.-- Parameters:- - wrapped (Callable): The Pinecone operation to be wrapped and executed.- - instance (object): The instance on which the operation is called (for class methods).- - args (tuple): Positional arguments for the Pinecone operation.- - kwargs (dict): Keyword arguments for the Pinecone operation.-- Returns:- - Any: The result of executing the wrapped Pinecone operation.+ Wraps the Pinecone function call."""- with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:- response = wrapped(*args, **kwargs)-- try:- span.set_attribute(TELEMETRY_SDK_NAME, "openlit")- span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,- gen_ai_endpoint)- span.set_attribute(DEPLOYMENT_ENVIRONMENT,- environment)- span.set_attribute(SERVICE_NAME,- application_name)- span.set_attribute(SemanticConvention.GEN_AI_OPERATION,- SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)- span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,- SemanticConvention.DB_SYSTEM_PINECONE)-- if gen_ai_endpoint == "pinecone.create_index":- db_operation = SemanticConvention.DB_OPERATION_CREATE_INDEX- span.set_attribute(SemanticConvention.DB_OPERATION_NAME,- SemanticConvention.DB_OPERATION_CREATE_INDEX)- span.set_attribute(SemanticConvention.DB_INDEX_NAME,- kwargs.get("name", ""))- span.set_attribute(SemanticConvention.DB_INDEX_DIMENSION,- kwargs.get("dimensions", ""))- span.set_attribute(SemanticConvention.DB_INDEX_METRIC,- kwargs.get("metric", ""))- span.set_attribute(SemanticConvention.DB_INDEX_SPEC,- str(kwargs.get("spec", "")))-- elif gen_ai_endpoint == "pinecone.query":- db_operation = SemanticConvention.DB_OPERATION_QUERY- span.set_attribute(SemanticConvention.DB_OPERATION_NAME,- SemanticConvention.DB_OPERATION_QUERY)- span.set_attribute(SemanticConvention.DB_STATEMENT,- str(kwargs.get("vector")))- span.set_attribute(SemanticConvention.DB_N_RESULTS,- kwargs.get("top_k", ""))- span.set_attribute(SemanticConvention.DB_FILTER,- str(kwargs.get("filter", "")))- span.set_attribute(SemanticConvention.DB_NAMESPACE,- str(kwargs.get("namespace", "")))+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):+ return wrapped(*args, **kwargs)- elif gen_ai_endpoint == "pinecone.update":- db_operation = SemanticConvention.DB_OPERATION_UPDATE- span.set_attribute(SemanticConvention.DB_OPERATION_NAME,- SemanticConvention.DB_OPERATION_UPDATE)- span.set_attribute(SemanticConvention.DB_UPDATE_ID,- kwargs.get("id",""))- span.set_attribute(SemanticConvention.DB_UPDATE_VALUES,- str(kwargs.get("values",[])))- span.set_attribute(SemanticConvention.DB_NAMESPACE,- str(kwargs.get("namespace", "")))- span.set_attribute(SemanticConvention.DB_UPDATE_METADATA,- str(kwargs.get("set_metadata", "")))+ # Get server address and port using the standard helper+ server_address, server_port = set_server_address_and_port(instance, "pinecone.io", 443)- elif gen_ai_endpoint == "pinecone.upsert":- db_operation = SemanticConvention.DB_OPERATION_UPSERT- span.set_attribute(SemanticConvention.DB_OPERATION_NAME,- SemanticConvention.DB_OPERATION_UPSERT)- span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,- object_count(kwargs.get("vectors")))+ db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "unknown")+ if db_operation == "create_collection":+ namespace = kwargs.get("name") or (args[0] if args else "unknown")+ else:+ namespace = kwargs.get("namespace") or (args[0] if args else "unknown")+ span_name = f"{db_operation} {namespace}"- elif gen_ai_endpoint == "pinecone.delete":- db_operation = SemanticConvention.DB_OPERATION_DELETE- span.set_attribute(SemanticConvention.DB_OPERATION_NAME,- SemanticConvention.DB_OPERATION_DELETE)- span.set_attribute(SemanticConvention.DB_ID_COUNT,- object_count(kwargs.get("ids")))- span.set_attribute(SemanticConvention.DB_FILTER,- str(kwargs.get("filter", "")))- span.set_attribute(SemanticConvention.DB_DELETE_ALL,- kwargs.get("delete_all", False))- span.set_attribute(SemanticConvention.DB_NAMESPACE,- kwargs.get("namespace", ""))-- span.set_status(Status(StatusCode.OK))-- if disable_metrics is False:- attributes = {- TELEMETRY_SDK_NAME:- "openlit",- SERVICE_NAME:- application_name,- SemanticConvention.DB_SYSTEM_NAME:- SemanticConvention.DB_SYSTEM_PINECONE,- DEPLOYMENT_ENVIRONMENT:- environment,- SemanticConvention.GEN_AI_OPERATION:- SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,- SemanticConvention.DB_OPERATION_NAME:- db_operation- }+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:+ try:+ start_time = time.time()+ response = wrapped(*args, **kwargs)- metrics["db_requests"].add(1, attributes)+ # Process response and generate telemetry+ response = process_vectordb_response(+ response, db_operation, server_address, server_port,+ environment, application_name, metrics, start_time, span,+ capture_message_content, disable_metrics, version, instance, args, **kwargs+ )- # Return original responsereturn responseexcept Exception as e:handle_exception(span, e)- logger.error("Error in trace creation: %s", e)-- # Return original response- return response+ raisereturn wrapperdiff --git a/sdk/python/src/openlit/instrumentation/pinecone/utils.py b/sdk/python/src/openlit/instrumentation/pinecone/utils.pynew file mode 100644index 00000000..24ef8752--- /dev/null+++ b/sdk/python/src/openlit/instrumentation/pinecone/utils.py@@ -0,0 +1,182 @@+"""+Pinecone OpenTelemetry instrumentation utility functions+"""+import time++from opentelemetry.trace import Status, StatusCode++from openlit.__helpers import (+ common_db_span_attributes,+ record_db_metrics,+)+from openlit.semcov import SemanticConvention++# Operation mapping for simple span naming+DB_OPERATION_MAP = {+ "pinecone.create_collection": SemanticConvention.DB_OPERATION_CREATE_COLLECTION,+ "pinecone.upsert": SemanticConvention.DB_OPERATION_UPSERT,+ "pinecone.query": SemanticConvention.DB_OPERATION_QUERY,+ "pinecone.search": SemanticConvention.DB_OPERATION_SEARCH,+ "pinecone.fetch": SemanticConvention.DB_OPERATION_FETCH,+ "pinecone.update": SemanticConvention.DB_OPERATION_UPDATE,+ "pinecone.delete": SemanticConvention.DB_OPERATION_DELETE,+ "pinecone.upsert_records": SemanticConvention.DB_OPERATION_UPSERT,+ "pinecone.search_records": SemanticConvention.DB_OPERATION_QUERY,+}++def object_count(obj):+ """+ Counts length of object if it exists, else returns 0.+ """+ return len(obj) if obj else 0++def common_vectordb_logic(scope, environment, application_name,+ metrics, capture_message_content, disable_metrics, version, instance=None):+ """+ Process vector database request and generate telemetry.+ """++ scope._end_time = time.time()++ # Set common database span attributes using helper+ common_db_span_attributes(scope, SemanticConvention.DB_SYSTEM_PINECONE, scope._server_address, scope._server_port,+ environment, application_name, version)++ # Set DB operation specific attributes+ scope._span.set_attribute(SemanticConvention.DB_OPERATION_NAME, scope._db_operation)+ scope._span.set_attribute(SemanticConvention.DB_CLIENT_OPERATION_DURATION, scope._end_time - scope._start_time)++ # Set Create Index operation specific attributes+ if scope._db_operation == SemanticConvention.DB_OPERATION_CREATE_COLLECTION:+ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_COLLECTION_NAME, scope._kwargs.get("name", ""))++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_COLLECTION_DIMENSION, scope._kwargs.get("dimension", -1))+ scope._span.set_attribute(SemanticConvention.DB_SEARCH_SIMILARITY_METRIC, scope._kwargs.get("metric", "cosine"))+ scope._span.set_attribute(SemanticConvention.DB_COLLECTION_SPEC, str(scope._kwargs.get("spec", "")))++ elif scope._db_operation == SemanticConvention.DB_OPERATION_SEARCH:+ namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("query", {})++ # Extract query text or vector from different possible locations+ query_text = query.get("inputs", {}).get("text", "")+ query_vector = query.get("vector", {})+ query_content = query_text or str(query_vector)++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, query_content)+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_VECTOR_QUERY_TOP_K, query.get("top_k", -1))+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"SEARCH {namespace} top_k={query.get('top_k', -1)} text={query_text} vector={query_vector}")++ elif scope._db_operation == SemanticConvention.DB_OPERATION_QUERY:+ namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("vector", [])++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_VECTOR_QUERY_TOP_K, scope._kwargs.get("top_k", ""))+ scope._span.set_attribute(SemanticConvention.DB_FILTER, str(scope._kwargs.get("filter", "")))+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"{scope._db_operation} {namespace} "+ f"top_k={scope._kwargs.get('top_k', -1)} "+ f"filtered={scope._kwargs.get('filter', '')} "+ f"vector={scope._kwargs.get('vector', '')}")++ elif scope._db_operation == SemanticConvention.DB_OPERATION_FETCH:+ namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("ids", [])++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"FETCH {namespace} ids={query}")+ scope._span.set_attribute(SemanticConvention.DB_RESPONSE_RETURNED_ROWS, object_count(scope._response.vectors))++ elif scope._db_operation == SemanticConvention.DB_OPERATION_UPDATE:+ namespace = scope._kwargs.get("namespace") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("id", "")++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, query)+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"{scope._db_operation} {namespace} "+ f"id={query} "+ f"values={scope._kwargs.get('values', [])} "+ f"set_metadata={scope._kwargs.get('set_metadata', '')}")++ elif scope._db_operation == SemanticConvention.DB_OPERATION_UPSERT:+ namespace = scope._kwargs.get("namespace") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("vectors") or (scope._args[1] if len(scope._args) > 1 else None)++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_VECTOR_COUNT, object_count(query))+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"{scope._db_operation} {namespace} vectors_count={object_count(query)}")++ elif scope._db_operation == SemanticConvention.DB_OPERATION_DELETE:+ namespace = scope._kwargs.get("namespace") or (scope._args[0] if scope._args else "unknown")+ query = scope._kwargs.get("ids") or (scope._args[1] if len(scope._args) > 1 else None)++ # Standard database attributes+ scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))+ scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)++ # Vector database specific attributes (extensions)+ scope._span.set_attribute(SemanticConvention.DB_ID_COUNT, object_count(scope._kwargs.get("ids")))+ scope._span.set_attribute(SemanticConvention.DB_FILTER, str(scope._kwargs.get("filter", "")))+ scope._span.set_attribute(SemanticConvention.DB_DELETE_ALL, scope._kwargs.get("delete_all", False))+ scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,+ f"{scope._db_operation} {namespace} "+ f"ids={query} "+ f"filter={scope._kwargs.get('filter', '')} "+ f"delete_all={scope._kwargs.get('delete_all', False)}")++ scope._span.set_status(Status(StatusCode.OK))++ # Record metrics using helper+ if not disable_metrics:+ record_db_metrics(metrics, SemanticConvention.DB_SYSTEM_PINECONE, scope._server_address, scope._server_port,+ environment, application_name, scope._start_time, scope._end_time)++def process_vectordb_response(response, db_operation, server_address, server_port,+ environment, application_name, metrics, start_time, span,+ capture_message_content=False, disable_metrics=False,+ version="1.0.0", instance=None, args=None, **kwargs):+ """+ Process vector database response and generate telemetry following OpenTelemetry conventions.+ """++ scope = type("GenericScope", (), {})()++ scope._start_time = start_time+ scope._span = span+ scope._kwargs = kwargs+ scope._args = args or []+ scope._db_operation = db_operation+ scope._response = response+ scope._server_address = server_address+ scope._server_port = server_port++ common_vectordb_logic(scope, environment, application_name,+ metrics, capture_message_content, disable_metrics, version, instance)++ return responsediff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.pyindex e0cc8b82..86495dec 100644--- a/sdk/python/src/openlit/semcov/__init__.py+++ b/sdk/python/src/openlit/semcov/__init__.py@@ -23,6 +23,7 @@ class SemanticConvention:# GenAI Metric Names (OTel Semconv)GEN_AI_CLIENT_TOKEN_USAGE = "gen_ai.client.token.usage"+ DB_CLIENT_TOKEN_USAGE = "db.client.token.usage"GEN_AI_CLIENT_OPERATION_DURATION = "gen_ai.client.operation.duration"GEN_AI_SERVER_REQUEST_DURATION = "gen_ai.server.request.duration"GEN_AI_SERVER_TBT = "gen_ai.server.time_per_output_token"@@ -56,9 +57,12 @@ class SemanticConvention:GEN_AI_RESPONSE_FINISH_REASON = "gen_ai.response.finish_reasons"GEN_AI_RESPONSE_ID = "gen_ai.response.id"GEN_AI_RESPONSE_MODEL = "gen_ai.response.model"+GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens"GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens"GEN_AI_USAGE_REASONING_TOKENS = "gen_ai.usage.reasoning_tokens"+ GEN_AI_USAGE_READ_UNITS = "gen_ai.usage.read_units"+ GEN_AI_USAGE_RERANK_UNITS = "gen_ai.usage.rerank_units"GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id"GEN_AI_TOOL_NAME = "gen_ai.tool.name"GEN_AI_TOOL_ARGS = "gen_ai.tool.args"@@ -190,6 +194,7 @@ class SemanticConvention:DB_NAMESPACE = "db.namespace"DB_OPERATION_NAME = "db.operation.name"DB_QUERY_TEXT = "db.query.text"+ DB_QUERY_SUMMARY = "db.query.summary"DB_RESPONSE_RETURNED_ROWS = "db.response.returned_rows"@@ -208,6 +213,8 @@ class SemanticConvention:DB_OPERATION_INSERT = "INSERT"DB_OPERATION_SELECT = "SELECT"DB_OPERATION_QUERY = "QUERY"+ DB_OPERATION_SEARCH = "SEARCH"+ DB_OPERATION_FETCH = "FETCH"DB_OPERATION_REPLACE = "findAndModify"DB_OPERATION_FIND_AND_DELETE = "findAndDelete"DB_OPERATION_DELETE = "DELETE"@@ -217,7 +224,7 @@ class SemanticConvention:DB_OPERATION_ADD = "ADD"DB_OPERATION_PEEK = "peePEEKk"DB_ID_COUNT = "db.ids_count"- DB_VECTOR_COUNT = "db.vector_count"+ DB_VECTOR_COUNT = "db.vector.count"DB_METADATA = "db.metadata"DB_METADATA_COUNT = "db.metadatas_count"DB_DOCUMENTS_COUNT = "db.documents_count"@@ -230,15 +237,20 @@ class SemanticConvention:DB_N_RESULTS = "db.n_results"DB_DELETE_ALL = "db.delete_all"DB_INDEX_NAME = "db.index.name"+ DB_COLLECTION_DIMENSION = "db.collection.dimension"DB_INDEX_DIMENSION = "db.index.dimension"DB_COLLECTION_DIMENSION = "db.collection.dimension"+ DB_SEARCH_SIMILARITY_METRIC = "db.search.similarity_metric"DB_INDEX_METRIC = "db.create_index.metric"+ DB_COLLECTION_SPEC = "db.collection.spec"DB_INDEX_SPEC = "db.create_index.spec"DB_NAMESPACE = "db.query.namespace"DB_UPDATE_METADATA = "db.update.metadata"DB_UPDATE_VALUES = "db.update.values"DB_UPDATE_ID = "db.update.id"DB_DELETE_ID = "db.delete.id"+ DB_VECTOR_QUERY_TOP_K = "db.vector.query.top_k"+ DB_VECTOR_QUERY_FILTER = "db.vector.query.filter"DB_SYSTEM_CHROMA = "chroma"DB_SYSTEM_PINECONE = "pinecone"diff --git a/sdk/python/tests/test_together.py b/sdk/python/tests/test_together.pyindex 5330b210..57104682 100644--- a/sdk/python/tests/test_together.py+++ b/sdk/python/tests/test_together.py@@ -49,6 +49,8 @@ def test_sync_together_chat():except Exception as e:if "credit_limit" in str(e).lower():print("Insufficient balance:", e)+ elif "429" in str(e) or "rate limit" in str(e).lower():+ print("Rate limit exceeded:", e)else:raise@@ -73,6 +75,8 @@ def test_sync_together_image():except Exception as e:if "credit_limit" in str(e).lower():print("Insufficient balance:", e)+ elif "429" in str(e) or "rate limit" in str(e).lower():+ print("Rate limit exceeded:", e)else:raise@@ -102,6 +106,8 @@ async def test_async_together_chat():except Exception as e:if "credit_limit" in str(e).lower():print("Insufficient balance:", e)+ elif "429" in str(e) or "rate limit" in str(e).lower():+ print("Rate limit exceeded:", e)else:raise@@ -127,5 +133,7 @@ async def test_async_together_image():except Exception as e:if "credit_limit" in str(e).lower():print("Insufficient balance:", e)+ elif "429" in str(e) or "rate limit" in str(e).lower():+ print("Rate limit exceeded:", e)else:raise