openlit 1.34.23__tar.gz → 1.34.24__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openlit-1.34.23 → openlit-1.34.24}/PKG-INFO +1 -1
- {openlit-1.34.23 → openlit-1.34.24}/pyproject.toml +1 -1
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/__helpers.py +48 -3
- openlit-1.34.24/src/openlit/instrumentation/pinecone/__init__.py +174 -0
- openlit-1.34.24/src/openlit/instrumentation/pinecone/async_pinecone.py +59 -0
- openlit-1.34.24/src/openlit/instrumentation/pinecone/pinecone.py +59 -0
- openlit-1.34.24/src/openlit/instrumentation/pinecone/utils.py +182 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/semcov/__init__.py +13 -1
- openlit-1.34.23/src/openlit/instrumentation/pinecone/__init__.py +0 -66
- openlit-1.34.23/src/openlit/instrumentation/pinecone/pinecone.py +0 -173
- {openlit-1.34.23 → openlit-1.34.24}/LICENSE +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/README.md +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/evals/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/evals/all.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/evals/bias_detection.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/evals/hallucination.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/evals/toxicity.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/evals/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/guard/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/guard/all.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/guard/prompt_injection.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/guard/restrict_topic.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/guard/sensitive_topic.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/guard/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ag2/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ag2/ag2.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ag2/async_ag2.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ag2/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ai21/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ai21/ai21.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ai21/async_ai21.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ai21/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/anthropic/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/anthropic/anthropic.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/anthropic/async_anthropic.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/anthropic/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/assemblyai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/assemblyai/assemblyai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/assemblyai/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/astra/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/astra/astra.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/astra/async_astra.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/astra/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/azure_ai_inference/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/azure_ai_inference/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/bedrock/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/bedrock/bedrock.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/bedrock/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/chroma/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/chroma/chroma.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/cohere/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/cohere/async_cohere.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/cohere/cohere.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/cohere/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/controlflow/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/controlflow/controlflow.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/crawl4ai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/crawl4ai/async_crawl4ai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/crawl4ai/crawl4ai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/crewai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/crewai/crewai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/dynamiq/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/dynamiq/dynamiq.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/elevenlabs/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/elevenlabs/async_elevenlabs.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/elevenlabs/elevenlabs.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/elevenlabs/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/embedchain/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/embedchain/embedchain.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/firecrawl/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/firecrawl/firecrawl.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/google_ai_studio/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/google_ai_studio/google_ai_studio.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/google_ai_studio/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/gpt4all/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/gpt4all/gpt4all.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/gpt4all/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/gpu/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/groq/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/groq/async_groq.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/groq/groq.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/groq/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/haystack/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/haystack/haystack.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/julep/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/julep/async_julep.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/julep/julep.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain/async_langchain.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain/langchain.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain_community/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain_community/async_langchain_community.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain_community/langchain_community.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/langchain_community/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/letta/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/letta/letta.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/litellm/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/litellm/async_litellm.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/litellm/litellm.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/litellm/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/llamaindex/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/llamaindex/llamaindex.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/mem0/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/mem0/mem0.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/milvus/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/milvus/milvus.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/mistral/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/mistral/async_mistral.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/mistral/mistral.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/mistral/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/multion/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/multion/async_multion.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/multion/multion.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ollama/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ollama/async_ollama.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ollama/ollama.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/ollama/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/openai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/openai/async_openai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/openai/openai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/openai/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/openai_agents/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/openai_agents/openai_agents.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/phidata/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/phidata/phidata.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/premai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/premai/premai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/premai/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/pydantic_ai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/pydantic_ai/pydantic_ai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/pydantic_ai/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/qdrant/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/qdrant/async_qdrant.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/qdrant/qdrant.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/reka/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/reka/async_reka.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/reka/reka.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/reka/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/together/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/together/async_together.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/together/together.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/together/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/transformers/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/transformers/transformers.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/transformers/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vertexai/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vertexai/async_vertexai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vertexai/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vertexai/vertexai.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vllm/__init__.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vllm/utils.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/instrumentation/vllm/vllm.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/otel/events.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/otel/metrics.py +0 -0
- {openlit-1.34.23 → openlit-1.34.24}/src/openlit/otel/tracing.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: openlit
|
3
|
-
Version: 1.34.
|
3
|
+
Version: 1.34.24
|
4
4
|
Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
|
5
5
|
License: Apache-2.0
|
6
6
|
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "openlit"
|
3
|
-
version = "1.34.
|
3
|
+
version = "1.34.24"
|
4
4
|
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
|
5
5
|
authors = ["OpenLIT"]
|
6
6
|
license = "Apache-2.0"
|
@@ -205,11 +205,22 @@ def set_server_address_and_port(client_instance: Any,
|
|
205
205
|
config = getattr(client_instance, 'sdk_configuration', None)
|
206
206
|
base_url = getattr(config, 'server_url', None)
|
207
207
|
|
208
|
+
if not base_url:
|
209
|
+
# Attempt to get host from instance.config.host (used by Pinecone and other vector DBs)
|
210
|
+
config = getattr(client_instance, 'config', None)
|
211
|
+
base_url = getattr(config, 'host', None)
|
212
|
+
|
208
213
|
if base_url:
|
209
214
|
if isinstance(base_url, str):
|
210
|
-
|
211
|
-
|
212
|
-
|
215
|
+
# Check if it's a full URL or just a hostname
|
216
|
+
if base_url.startswith(('http://', 'https://')):
|
217
|
+
url = urlparse(base_url)
|
218
|
+
server_address = url.hostname or default_server_address
|
219
|
+
server_port = url.port if url.port is not None else default_server_port
|
220
|
+
else:
|
221
|
+
# If it's just a hostname (like Pinecone's case), use it directly
|
222
|
+
server_address = base_url
|
223
|
+
server_port = default_server_port
|
213
224
|
else: # base_url might not be a str; handle as an object.
|
214
225
|
server_address = getattr(base_url, 'host', None) or default_server_address
|
215
226
|
port_attr = getattr(base_url, 'port', None)
|
@@ -442,3 +453,37 @@ def record_image_metrics(metrics, gen_ai_operation, gen_ai_system, server_addres
|
|
442
453
|
metrics["genai_client_operation_duration"].record(end_time - start_time, attributes)
|
443
454
|
metrics["genai_requests"].add(1, attributes)
|
444
455
|
metrics["genai_cost"].record(cost, attributes)
|
456
|
+
|
457
|
+
def common_db_span_attributes(scope, db_system, server_address, server_port,
|
458
|
+
environment, application_name, version):
|
459
|
+
"""
|
460
|
+
Set common span attributes for database operations.
|
461
|
+
"""
|
462
|
+
|
463
|
+
scope._span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
464
|
+
scope._span.set_attribute(SemanticConvention.GEN_AI_OPERATION, SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
|
465
|
+
scope._span.set_attribute(SemanticConvention.DB_SYSTEM_NAME, db_system)
|
466
|
+
scope._span.set_attribute(SemanticConvention.SERVER_ADDRESS, server_address)
|
467
|
+
scope._span.set_attribute(SemanticConvention.SERVER_PORT, server_port)
|
468
|
+
scope._span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
|
469
|
+
scope._span.set_attribute(SERVICE_NAME, application_name)
|
470
|
+
scope._span.set_attribute(SemanticConvention.DB_SDK_VERSION, version)
|
471
|
+
|
472
|
+
def record_db_metrics(metrics, db_system, server_address, server_port,
|
473
|
+
environment, application_name, start_time, end_time):
|
474
|
+
"""
|
475
|
+
Record database-specific metrics for the operation.
|
476
|
+
"""
|
477
|
+
|
478
|
+
attributes = create_metrics_attributes(
|
479
|
+
operation=SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
|
480
|
+
system=db_system,
|
481
|
+
request_model=db_system,
|
482
|
+
server_address=server_address,
|
483
|
+
server_port=server_port,
|
484
|
+
response_model=db_system,
|
485
|
+
service_name=application_name,
|
486
|
+
deployment_environment=environment,
|
487
|
+
)
|
488
|
+
metrics["db_requests"].add(1, attributes)
|
489
|
+
metrics["db_client_operation_duration"].record(end_time - start_time, attributes)
|
@@ -0,0 +1,174 @@
|
|
1
|
+
"""Initializer of Auto Instrumentation of Pinecone Functions"""
|
2
|
+
|
3
|
+
from typing import Collection
|
4
|
+
import importlib.metadata
|
5
|
+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
6
|
+
from wrapt import wrap_function_wrapper
|
7
|
+
|
8
|
+
from openlit.instrumentation.pinecone.pinecone import general_wrap
|
9
|
+
from openlit.instrumentation.pinecone.async_pinecone import async_general_wrap
|
10
|
+
|
11
|
+
_instruments = ("pinecone >= 7.3.0",)
|
12
|
+
|
13
|
+
class PineconeInstrumentor(BaseInstrumentor):
|
14
|
+
"""
|
15
|
+
An instrumentor for Pinecone's client library.
|
16
|
+
"""
|
17
|
+
|
18
|
+
def instrumentation_dependencies(self) -> Collection[str]:
|
19
|
+
return _instruments
|
20
|
+
|
21
|
+
def _instrument(self, **kwargs):
|
22
|
+
version = importlib.metadata.version("pinecone")
|
23
|
+
environment = kwargs.get("environment", "default")
|
24
|
+
application_name = kwargs.get("application_name", "default")
|
25
|
+
tracer = kwargs.get("tracer")
|
26
|
+
pricing_info = kwargs.get("pricing_info", {})
|
27
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
28
|
+
metrics = kwargs.get("metrics_dict")
|
29
|
+
disable_metrics = kwargs.get("disable_metrics")
|
30
|
+
|
31
|
+
# Sync operations
|
32
|
+
wrap_function_wrapper(
|
33
|
+
"pinecone.pinecone",
|
34
|
+
"Pinecone.create_index",
|
35
|
+
general_wrap("pinecone.create_collection", version, environment, application_name,
|
36
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
37
|
+
)
|
38
|
+
|
39
|
+
wrap_function_wrapper(
|
40
|
+
"pinecone.pinecone",
|
41
|
+
"Pinecone.create_index_for_model",
|
42
|
+
general_wrap("pinecone.create_collection", version, environment, application_name,
|
43
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
44
|
+
)
|
45
|
+
|
46
|
+
wrap_function_wrapper(
|
47
|
+
"pinecone.db_data.index",
|
48
|
+
"Index.upsert",
|
49
|
+
general_wrap("pinecone.upsert", version, environment, application_name,
|
50
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
51
|
+
)
|
52
|
+
|
53
|
+
wrap_function_wrapper(
|
54
|
+
"pinecone.db_data.index",
|
55
|
+
"Index.upsert_records",
|
56
|
+
general_wrap("pinecone.upsert_records", version, environment, application_name,
|
57
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
58
|
+
)
|
59
|
+
|
60
|
+
wrap_function_wrapper(
|
61
|
+
"pinecone.db_data.index",
|
62
|
+
"Index.query",
|
63
|
+
general_wrap("pinecone.query", version, environment, application_name,
|
64
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
65
|
+
)
|
66
|
+
|
67
|
+
wrap_function_wrapper(
|
68
|
+
"pinecone.db_data.index",
|
69
|
+
"Index.search",
|
70
|
+
general_wrap("pinecone.search", version, environment, application_name,
|
71
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
72
|
+
)
|
73
|
+
|
74
|
+
wrap_function_wrapper(
|
75
|
+
"pinecone.db_data.index",
|
76
|
+
"Index.fetch",
|
77
|
+
general_wrap("pinecone.fetch", version, environment, application_name,
|
78
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
79
|
+
)
|
80
|
+
|
81
|
+
wrap_function_wrapper(
|
82
|
+
"pinecone.db_data.index",
|
83
|
+
"Index.search_records",
|
84
|
+
general_wrap("pinecone.search_records", version, environment, application_name,
|
85
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
86
|
+
)
|
87
|
+
|
88
|
+
wrap_function_wrapper(
|
89
|
+
"pinecone.db_data.index",
|
90
|
+
"Index.update",
|
91
|
+
general_wrap("pinecone.update", version, environment, application_name,
|
92
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
93
|
+
)
|
94
|
+
|
95
|
+
wrap_function_wrapper(
|
96
|
+
"pinecone.db_data.index",
|
97
|
+
"Index.delete",
|
98
|
+
general_wrap("pinecone.delete", version, environment, application_name,
|
99
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
100
|
+
)
|
101
|
+
|
102
|
+
# Async operations
|
103
|
+
wrap_function_wrapper(
|
104
|
+
"pinecone.pinecone_asyncio",
|
105
|
+
"PineconeAsyncio.create_index",
|
106
|
+
async_general_wrap("pinecone.create_index", version, environment, application_name,
|
107
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
108
|
+
)
|
109
|
+
|
110
|
+
wrap_function_wrapper(
|
111
|
+
"pinecone.pinecone_asyncio",
|
112
|
+
"PineconeAsyncio.create_index_for_model",
|
113
|
+
async_general_wrap("pinecone.create_index", version, environment, application_name,
|
114
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
115
|
+
)
|
116
|
+
|
117
|
+
wrap_function_wrapper(
|
118
|
+
"pinecone.db_data.index_asyncio",
|
119
|
+
"_IndexAsyncio.upsert",
|
120
|
+
async_general_wrap("pinecone.upsert", version, environment, application_name,
|
121
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
122
|
+
)
|
123
|
+
|
124
|
+
wrap_function_wrapper(
|
125
|
+
"pinecone.db_data.index_asyncio",
|
126
|
+
"_IndexAsyncio.upsert_records",
|
127
|
+
async_general_wrap("pinecone.upsert_records", version, environment, application_name,
|
128
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
129
|
+
)
|
130
|
+
|
131
|
+
wrap_function_wrapper(
|
132
|
+
"pinecone.db_data.index_asyncio",
|
133
|
+
"_IndexAsyncio.query",
|
134
|
+
async_general_wrap("pinecone.query", version, environment, application_name,
|
135
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
136
|
+
)
|
137
|
+
|
138
|
+
wrap_function_wrapper(
|
139
|
+
"pinecone.db_data.index_asyncio",
|
140
|
+
"_IndexAsyncio.search",
|
141
|
+
async_general_wrap("pinecone.search", version, environment, application_name,
|
142
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
143
|
+
)
|
144
|
+
|
145
|
+
wrap_function_wrapper(
|
146
|
+
"pinecone.db_data.index_asyncio",
|
147
|
+
"_IndexAsyncio.fetch",
|
148
|
+
async_general_wrap("pinecone.fetch", version, environment, application_name,
|
149
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
150
|
+
)
|
151
|
+
|
152
|
+
wrap_function_wrapper(
|
153
|
+
"pinecone.db_data.index_asyncio",
|
154
|
+
"_IndexAsyncio.search_records",
|
155
|
+
async_general_wrap("pinecone.search_records", version, environment, application_name,
|
156
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
157
|
+
)
|
158
|
+
|
159
|
+
wrap_function_wrapper(
|
160
|
+
"pinecone.db_data.index_asyncio",
|
161
|
+
"_IndexAsyncio.update",
|
162
|
+
async_general_wrap("pinecone.update", version, environment, application_name,
|
163
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
164
|
+
)
|
165
|
+
|
166
|
+
wrap_function_wrapper(
|
167
|
+
"pinecone.db_data.index_asyncio",
|
168
|
+
"_IndexAsyncio.delete",
|
169
|
+
async_general_wrap("pinecone.delete", version, environment, application_name,
|
170
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
171
|
+
)
|
172
|
+
|
173
|
+
def _uninstrument(self, **kwargs):
|
174
|
+
pass
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring Pinecone async API calls.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import time
|
6
|
+
from opentelemetry.trace import SpanKind
|
7
|
+
from opentelemetry import context as context_api
|
8
|
+
from openlit.__helpers import (
|
9
|
+
handle_exception,
|
10
|
+
set_server_address_and_port,
|
11
|
+
)
|
12
|
+
from openlit.instrumentation.pinecone.utils import (
|
13
|
+
process_vectordb_response,
|
14
|
+
DB_OPERATION_MAP,
|
15
|
+
)
|
16
|
+
|
17
|
+
def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
18
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
19
|
+
"""
|
20
|
+
Generates a telemetry wrapper for Pinecone async function calls.
|
21
|
+
"""
|
22
|
+
|
23
|
+
async def wrapper(wrapped, instance, args, kwargs):
|
24
|
+
"""
|
25
|
+
Wraps the Pinecone async function call.
|
26
|
+
"""
|
27
|
+
|
28
|
+
if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
|
29
|
+
return await wrapped(*args, **kwargs)
|
30
|
+
|
31
|
+
# Get server address and port using the standard helper
|
32
|
+
server_address, server_port = set_server_address_and_port(instance, "pinecone.io", 443)
|
33
|
+
|
34
|
+
db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "unknown")
|
35
|
+
if db_operation == "create_collection":
|
36
|
+
namespace = kwargs.get("name") or (args[0] if args else "unknown")
|
37
|
+
else:
|
38
|
+
namespace = kwargs.get("namespace") or (args[0] if args else "unknown")
|
39
|
+
span_name = f"{db_operation} {namespace}"
|
40
|
+
|
41
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
42
|
+
try:
|
43
|
+
start_time = time.time()
|
44
|
+
response = await wrapped(*args, **kwargs)
|
45
|
+
|
46
|
+
# Process response and generate telemetry
|
47
|
+
response = process_vectordb_response(
|
48
|
+
response, db_operation, server_address, server_port,
|
49
|
+
environment, application_name, metrics, start_time, span,
|
50
|
+
capture_message_content, disable_metrics, version, instance, args, **kwargs
|
51
|
+
)
|
52
|
+
|
53
|
+
return response
|
54
|
+
|
55
|
+
except Exception as e:
|
56
|
+
handle_exception(span, e)
|
57
|
+
raise
|
58
|
+
|
59
|
+
return wrapper
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"""
|
2
|
+
Module for monitoring Pinecone API calls.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import time
|
6
|
+
from opentelemetry.trace import SpanKind
|
7
|
+
from opentelemetry import context as context_api
|
8
|
+
from openlit.__helpers import (
|
9
|
+
handle_exception,
|
10
|
+
set_server_address_and_port,
|
11
|
+
)
|
12
|
+
from openlit.instrumentation.pinecone.utils import (
|
13
|
+
process_vectordb_response,
|
14
|
+
DB_OPERATION_MAP,
|
15
|
+
)
|
16
|
+
|
17
|
+
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
18
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
19
|
+
"""
|
20
|
+
Generates a telemetry wrapper for Pinecone function calls.
|
21
|
+
"""
|
22
|
+
|
23
|
+
def wrapper(wrapped, instance, args, kwargs):
|
24
|
+
"""
|
25
|
+
Wraps the Pinecone function call.
|
26
|
+
"""
|
27
|
+
|
28
|
+
if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
|
29
|
+
return wrapped(*args, **kwargs)
|
30
|
+
|
31
|
+
# Get server address and port using the standard helper
|
32
|
+
server_address, server_port = set_server_address_and_port(instance, "pinecone.io", 443)
|
33
|
+
|
34
|
+
db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "unknown")
|
35
|
+
if db_operation == "create_collection":
|
36
|
+
namespace = kwargs.get("name") or (args[0] if args else "unknown")
|
37
|
+
else:
|
38
|
+
namespace = kwargs.get("namespace") or (args[0] if args else "unknown")
|
39
|
+
span_name = f"{db_operation} {namespace}"
|
40
|
+
|
41
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
42
|
+
try:
|
43
|
+
start_time = time.time()
|
44
|
+
response = wrapped(*args, **kwargs)
|
45
|
+
|
46
|
+
# Process response and generate telemetry
|
47
|
+
response = process_vectordb_response(
|
48
|
+
response, db_operation, server_address, server_port,
|
49
|
+
environment, application_name, metrics, start_time, span,
|
50
|
+
capture_message_content, disable_metrics, version, instance, args, **kwargs
|
51
|
+
)
|
52
|
+
|
53
|
+
return response
|
54
|
+
|
55
|
+
except Exception as e:
|
56
|
+
handle_exception(span, e)
|
57
|
+
raise
|
58
|
+
|
59
|
+
return wrapper
|
@@ -0,0 +1,182 @@
|
|
1
|
+
"""
|
2
|
+
Pinecone OpenTelemetry instrumentation utility functions
|
3
|
+
"""
|
4
|
+
import time
|
5
|
+
|
6
|
+
from opentelemetry.trace import Status, StatusCode
|
7
|
+
|
8
|
+
from openlit.__helpers import (
|
9
|
+
common_db_span_attributes,
|
10
|
+
record_db_metrics,
|
11
|
+
)
|
12
|
+
from openlit.semcov import SemanticConvention
|
13
|
+
|
14
|
+
# Operation mapping for simple span naming
|
15
|
+
DB_OPERATION_MAP = {
|
16
|
+
"pinecone.create_collection": SemanticConvention.DB_OPERATION_CREATE_COLLECTION,
|
17
|
+
"pinecone.upsert": SemanticConvention.DB_OPERATION_UPSERT,
|
18
|
+
"pinecone.query": SemanticConvention.DB_OPERATION_QUERY,
|
19
|
+
"pinecone.search": SemanticConvention.DB_OPERATION_SEARCH,
|
20
|
+
"pinecone.fetch": SemanticConvention.DB_OPERATION_FETCH,
|
21
|
+
"pinecone.update": SemanticConvention.DB_OPERATION_UPDATE,
|
22
|
+
"pinecone.delete": SemanticConvention.DB_OPERATION_DELETE,
|
23
|
+
"pinecone.upsert_records": SemanticConvention.DB_OPERATION_UPSERT,
|
24
|
+
"pinecone.search_records": SemanticConvention.DB_OPERATION_QUERY,
|
25
|
+
}
|
26
|
+
|
27
|
+
def object_count(obj):
|
28
|
+
"""
|
29
|
+
Counts length of object if it exists, else returns 0.
|
30
|
+
"""
|
31
|
+
return len(obj) if obj else 0
|
32
|
+
|
33
|
+
def common_vectordb_logic(scope, environment, application_name,
|
34
|
+
metrics, capture_message_content, disable_metrics, version, instance=None):
|
35
|
+
"""
|
36
|
+
Process vector database request and generate telemetry.
|
37
|
+
"""
|
38
|
+
|
39
|
+
scope._end_time = time.time()
|
40
|
+
|
41
|
+
# Set common database span attributes using helper
|
42
|
+
common_db_span_attributes(scope, SemanticConvention.DB_SYSTEM_PINECONE, scope._server_address, scope._server_port,
|
43
|
+
environment, application_name, version)
|
44
|
+
|
45
|
+
# Set DB operation specific attributes
|
46
|
+
scope._span.set_attribute(SemanticConvention.DB_OPERATION_NAME, scope._db_operation)
|
47
|
+
scope._span.set_attribute(SemanticConvention.DB_CLIENT_OPERATION_DURATION, scope._end_time - scope._start_time)
|
48
|
+
|
49
|
+
# Set Create Index operation specific attributes
|
50
|
+
if scope._db_operation == SemanticConvention.DB_OPERATION_CREATE_COLLECTION:
|
51
|
+
# Standard database attributes
|
52
|
+
scope._span.set_attribute(SemanticConvention.DB_COLLECTION_NAME, scope._kwargs.get("name", ""))
|
53
|
+
|
54
|
+
# Vector database specific attributes (extensions)
|
55
|
+
scope._span.set_attribute(SemanticConvention.DB_COLLECTION_DIMENSION, scope._kwargs.get("dimension", -1))
|
56
|
+
scope._span.set_attribute(SemanticConvention.DB_SEARCH_SIMILARITY_METRIC, scope._kwargs.get("metric", "cosine"))
|
57
|
+
scope._span.set_attribute(SemanticConvention.DB_COLLECTION_SPEC, str(scope._kwargs.get("spec", "")))
|
58
|
+
|
59
|
+
elif scope._db_operation == SemanticConvention.DB_OPERATION_SEARCH:
|
60
|
+
namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")
|
61
|
+
query = scope._kwargs.get("query", {})
|
62
|
+
|
63
|
+
# Extract query text or vector from different possible locations
|
64
|
+
query_text = query.get("inputs", {}).get("text", "")
|
65
|
+
query_vector = query.get("vector", {})
|
66
|
+
query_content = query_text or str(query_vector)
|
67
|
+
|
68
|
+
# Standard database attributes
|
69
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, query_content)
|
70
|
+
scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)
|
71
|
+
|
72
|
+
# Vector database specific attributes (extensions)
|
73
|
+
scope._span.set_attribute(SemanticConvention.DB_VECTOR_QUERY_TOP_K, query.get("top_k", -1))
|
74
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
|
75
|
+
f"SEARCH {namespace} top_k={query.get('top_k', -1)} text={query_text} vector={query_vector}")
|
76
|
+
|
77
|
+
elif scope._db_operation == SemanticConvention.DB_OPERATION_QUERY:
|
78
|
+
namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")
|
79
|
+
query = scope._kwargs.get("vector", [])
|
80
|
+
|
81
|
+
# Standard database attributes
|
82
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))
|
83
|
+
scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)
|
84
|
+
|
85
|
+
# Vector database specific attributes (extensions)
|
86
|
+
scope._span.set_attribute(SemanticConvention.DB_VECTOR_QUERY_TOP_K, scope._kwargs.get("top_k", ""))
|
87
|
+
scope._span.set_attribute(SemanticConvention.DB_FILTER, str(scope._kwargs.get("filter", "")))
|
88
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
|
89
|
+
f"{scope._db_operation} {namespace} "
|
90
|
+
f"top_k={scope._kwargs.get('top_k', -1)} "
|
91
|
+
f"filtered={scope._kwargs.get('filter', '')} "
|
92
|
+
f"vector={scope._kwargs.get('vector', '')}")
|
93
|
+
|
94
|
+
elif scope._db_operation == SemanticConvention.DB_OPERATION_FETCH:
|
95
|
+
namespace = scope._kwargs.get("namespace", "default") or (scope._args[0] if scope._args else "unknown")
|
96
|
+
query = scope._kwargs.get("ids", [])
|
97
|
+
|
98
|
+
# Standard database attributes
|
99
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))
|
100
|
+
scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)
|
101
|
+
|
102
|
+
# Vector database specific attributes (extensions)
|
103
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
|
104
|
+
f"FETCH {namespace} ids={query}")
|
105
|
+
scope._span.set_attribute(SemanticConvention.DB_RESPONSE_RETURNED_ROWS, object_count(scope._response.vectors))
|
106
|
+
|
107
|
+
elif scope._db_operation == SemanticConvention.DB_OPERATION_UPDATE:
|
108
|
+
namespace = scope._kwargs.get("namespace") or (scope._args[0] if scope._args else "unknown")
|
109
|
+
query = scope._kwargs.get("id", "")
|
110
|
+
|
111
|
+
# Standard database attributes
|
112
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, query)
|
113
|
+
scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)
|
114
|
+
|
115
|
+
# Vector database specific attributes (extensions)
|
116
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
|
117
|
+
f"{scope._db_operation} {namespace} "
|
118
|
+
f"id={query} "
|
119
|
+
f"values={scope._kwargs.get('values', [])} "
|
120
|
+
f"set_metadata={scope._kwargs.get('set_metadata', '')}")
|
121
|
+
|
122
|
+
elif scope._db_operation == SemanticConvention.DB_OPERATION_UPSERT:
|
123
|
+
namespace = scope._kwargs.get("namespace") or (scope._args[0] if scope._args else "unknown")
|
124
|
+
query = scope._kwargs.get("vectors") or (scope._args[1] if len(scope._args) > 1 else None)
|
125
|
+
|
126
|
+
# Standard database attributes
|
127
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))
|
128
|
+
scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)
|
129
|
+
|
130
|
+
# Vector database specific attributes (extensions)
|
131
|
+
scope._span.set_attribute(SemanticConvention.DB_VECTOR_COUNT, object_count(query))
|
132
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
|
133
|
+
f"{scope._db_operation} {namespace} vectors_count={object_count(query)}")
|
134
|
+
|
135
|
+
elif scope._db_operation == SemanticConvention.DB_OPERATION_DELETE:
|
136
|
+
namespace = scope._kwargs.get("namespace") or (scope._args[0] if scope._args else "unknown")
|
137
|
+
query = scope._kwargs.get("ids") or (scope._args[1] if len(scope._args) > 1 else None)
|
138
|
+
|
139
|
+
# Standard database attributes
|
140
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))
|
141
|
+
scope._span.set_attribute(SemanticConvention.DB_NAMESPACE, namespace)
|
142
|
+
|
143
|
+
# Vector database specific attributes (extensions)
|
144
|
+
scope._span.set_attribute(SemanticConvention.DB_ID_COUNT, object_count(scope._kwargs.get("ids")))
|
145
|
+
scope._span.set_attribute(SemanticConvention.DB_FILTER, str(scope._kwargs.get("filter", "")))
|
146
|
+
scope._span.set_attribute(SemanticConvention.DB_DELETE_ALL, scope._kwargs.get("delete_all", False))
|
147
|
+
scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
|
148
|
+
f"{scope._db_operation} {namespace} "
|
149
|
+
f"ids={query} "
|
150
|
+
f"filter={scope._kwargs.get('filter', '')} "
|
151
|
+
f"delete_all={scope._kwargs.get('delete_all', False)}")
|
152
|
+
|
153
|
+
scope._span.set_status(Status(StatusCode.OK))
|
154
|
+
|
155
|
+
# Record metrics using helper
|
156
|
+
if not disable_metrics:
|
157
|
+
record_db_metrics(metrics, SemanticConvention.DB_SYSTEM_PINECONE, scope._server_address, scope._server_port,
|
158
|
+
environment, application_name, scope._start_time, scope._end_time)
|
159
|
+
|
160
|
+
def process_vectordb_response(response, db_operation, server_address, server_port,
|
161
|
+
environment, application_name, metrics, start_time, span,
|
162
|
+
capture_message_content=False, disable_metrics=False,
|
163
|
+
version="1.0.0", instance=None, args=None, **kwargs):
|
164
|
+
"""
|
165
|
+
Process vector database response and generate telemetry following OpenTelemetry conventions.
|
166
|
+
"""
|
167
|
+
|
168
|
+
scope = type("GenericScope", (), {})()
|
169
|
+
|
170
|
+
scope._start_time = start_time
|
171
|
+
scope._span = span
|
172
|
+
scope._kwargs = kwargs
|
173
|
+
scope._args = args or []
|
174
|
+
scope._db_operation = db_operation
|
175
|
+
scope._response = response
|
176
|
+
scope._server_address = server_address
|
177
|
+
scope._server_port = server_port
|
178
|
+
|
179
|
+
common_vectordb_logic(scope, environment, application_name,
|
180
|
+
metrics, capture_message_content, disable_metrics, version, instance)
|
181
|
+
|
182
|
+
return response
|
@@ -23,6 +23,7 @@ class SemanticConvention:
|
|
23
23
|
|
24
24
|
# GenAI Metric Names (OTel Semconv)
|
25
25
|
GEN_AI_CLIENT_TOKEN_USAGE = "gen_ai.client.token.usage"
|
26
|
+
DB_CLIENT_TOKEN_USAGE = "db.client.token.usage"
|
26
27
|
GEN_AI_CLIENT_OPERATION_DURATION = "gen_ai.client.operation.duration"
|
27
28
|
GEN_AI_SERVER_REQUEST_DURATION = "gen_ai.server.request.duration"
|
28
29
|
GEN_AI_SERVER_TBT = "gen_ai.server.time_per_output_token"
|
@@ -56,9 +57,12 @@ class SemanticConvention:
|
|
56
57
|
GEN_AI_RESPONSE_FINISH_REASON = "gen_ai.response.finish_reasons"
|
57
58
|
GEN_AI_RESPONSE_ID = "gen_ai.response.id"
|
58
59
|
GEN_AI_RESPONSE_MODEL = "gen_ai.response.model"
|
60
|
+
|
59
61
|
GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens"
|
60
62
|
GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens"
|
61
63
|
GEN_AI_USAGE_REASONING_TOKENS = "gen_ai.usage.reasoning_tokens"
|
64
|
+
GEN_AI_USAGE_READ_UNITS = "gen_ai.usage.read_units"
|
65
|
+
GEN_AI_USAGE_RERANK_UNITS = "gen_ai.usage.rerank_units"
|
62
66
|
GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id"
|
63
67
|
GEN_AI_TOOL_NAME = "gen_ai.tool.name"
|
64
68
|
GEN_AI_TOOL_ARGS = "gen_ai.tool.args"
|
@@ -190,6 +194,7 @@ class SemanticConvention:
|
|
190
194
|
DB_NAMESPACE = "db.namespace"
|
191
195
|
DB_OPERATION_NAME = "db.operation.name"
|
192
196
|
DB_QUERY_TEXT = "db.query.text"
|
197
|
+
DB_QUERY_SUMMARY = "db.query.summary"
|
193
198
|
DB_RESPONSE_RETURNED_ROWS = "db.response.returned_rows"
|
194
199
|
|
195
200
|
|
@@ -208,6 +213,8 @@ class SemanticConvention:
|
|
208
213
|
DB_OPERATION_INSERT = "INSERT"
|
209
214
|
DB_OPERATION_SELECT = "SELECT"
|
210
215
|
DB_OPERATION_QUERY = "QUERY"
|
216
|
+
DB_OPERATION_SEARCH = "SEARCH"
|
217
|
+
DB_OPERATION_FETCH = "FETCH"
|
211
218
|
DB_OPERATION_REPLACE = "findAndModify"
|
212
219
|
DB_OPERATION_FIND_AND_DELETE = "findAndDelete"
|
213
220
|
DB_OPERATION_DELETE = "DELETE"
|
@@ -217,7 +224,7 @@ class SemanticConvention:
|
|
217
224
|
DB_OPERATION_ADD = "ADD"
|
218
225
|
DB_OPERATION_PEEK = "peePEEKk"
|
219
226
|
DB_ID_COUNT = "db.ids_count"
|
220
|
-
DB_VECTOR_COUNT = "db.
|
227
|
+
DB_VECTOR_COUNT = "db.vector.count"
|
221
228
|
DB_METADATA = "db.metadata"
|
222
229
|
DB_METADATA_COUNT = "db.metadatas_count"
|
223
230
|
DB_DOCUMENTS_COUNT = "db.documents_count"
|
@@ -230,15 +237,20 @@ class SemanticConvention:
|
|
230
237
|
DB_N_RESULTS = "db.n_results"
|
231
238
|
DB_DELETE_ALL = "db.delete_all"
|
232
239
|
DB_INDEX_NAME = "db.index.name"
|
240
|
+
DB_COLLECTION_DIMENSION = "db.collection.dimension"
|
233
241
|
DB_INDEX_DIMENSION = "db.index.dimension"
|
234
242
|
DB_COLLECTION_DIMENSION = "db.collection.dimension"
|
243
|
+
DB_SEARCH_SIMILARITY_METRIC = "db.search.similarity_metric"
|
235
244
|
DB_INDEX_METRIC = "db.create_index.metric"
|
245
|
+
DB_COLLECTION_SPEC = "db.collection.spec"
|
236
246
|
DB_INDEX_SPEC = "db.create_index.spec"
|
237
247
|
DB_NAMESPACE = "db.query.namespace"
|
238
248
|
DB_UPDATE_METADATA = "db.update.metadata"
|
239
249
|
DB_UPDATE_VALUES = "db.update.values"
|
240
250
|
DB_UPDATE_ID = "db.update.id"
|
241
251
|
DB_DELETE_ID = "db.delete.id"
|
252
|
+
DB_VECTOR_QUERY_TOP_K = "db.vector.query.top_k"
|
253
|
+
DB_VECTOR_QUERY_FILTER = "db.vector.query.filter"
|
242
254
|
|
243
255
|
DB_SYSTEM_CHROMA = "chroma"
|
244
256
|
DB_SYSTEM_PINECONE = "pinecone"
|