|
17 | 17 | import os |
18 | 18 | import sys |
19 | 19 | from typing import Optional |
20 | | - |
| 20 | +import importlib.util |
21 | 21 | from colorama import Fore |
22 | 22 | from opentelemetry import trace |
23 | 23 | from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor |
@@ -120,25 +120,25 @@ def init( |
120 | 120 | all_instrumentations = { |
121 | 121 | "openai": OpenAIInstrumentation(), |
122 | 122 | "groq": GroqInstrumentation(), |
123 | | - "pinecone": PineconeInstrumentation(), |
124 | | - "llamaindex": LlamaindexInstrumentation(), |
125 | | - "chroma": ChromaInstrumentation(), |
| 123 | + "pinecone-client": PineconeInstrumentation(), |
| 124 | + "llama-index": LlamaindexInstrumentation(), |
| 125 | + "chromadb": ChromaInstrumentation(), |
126 | 126 | "embedchain": EmbedchainInstrumentation(), |
127 | | - "qdrant": QdrantInstrumentation(), |
| 127 | + "qdrant-client": QdrantInstrumentation(), |
128 | 128 | "langchain": LangchainInstrumentation(), |
129 | | - "langchain_core": LangchainCoreInstrumentation(), |
130 | | - "langchain_community": LangchainCommunityInstrumentation(), |
| 129 | + "langchain-core": LangchainCoreInstrumentation(), |
| 130 | + "langchain-community": LangchainCommunityInstrumentation(), |
131 | 131 | "langgraph": LanggraphInstrumentation(), |
132 | 132 | "anthropic": AnthropicInstrumentation(), |
133 | 133 | "cohere": CohereInstrumentation(), |
134 | | - "weaviate": WeaviateInstrumentation(), |
| 134 | + "weaviate-client": WeaviateInstrumentation(), |
135 | 135 | "sqlalchemy": SQLAlchemyInstrumentor(), |
136 | 136 | "ollama": OllamaInstrumentor(), |
137 | | - "dspy": DspyInstrumentation(), |
| 137 | + "dspy-ai": DspyInstrumentation(), |
138 | 138 | "crewai": CrewAIInstrumentation(), |
139 | | - "vertexai": VertexAIInstrumentation(), |
140 | | - "gemini": GeminiInstrumentation(), |
141 | | - "mistral": MistralInstrumentation(), |
| 139 | + "google-cloud-aiplatform": VertexAIInstrumentation(), |
| 140 | + "google-generativeai": GeminiInstrumentation(), |
| 141 | + "mistralai": MistralInstrumentation(), |
142 | 142 | } |
143 | 143 |
|
144 | 144 | init_instrumentations(disable_instrumentations, all_instrumentations) |
@@ -171,8 +171,9 @@ def init_instrumentations( |
171 | 171 | ): |
172 | 172 | if disable_instrumentations is None: |
173 | 173 | for idx, (name, v) in enumerate(all_instrumentations.items()): |
| 174 | + if is_package_installed(name): |
| 175 | + v.instrument() |
174 | 176 |
|
175 | | - v.instrument() |
176 | 177 | else: |
177 | 178 |
|
178 | 179 | validate_instrumentations(disable_instrumentations) |
@@ -229,3 +230,10 @@ def validate_instrumentations(disable_instrumentations): |
229 | 230 | raise ValueError( |
230 | 231 | "Cannot specify both only and all_except in disable_instrumentations" |
231 | 232 | ) |
| 233 | + |
| 234 | + |
| 235 | +def is_package_installed(package_name): |
| 236 | + import pkg_resources |
| 237 | + |
| 238 | + installed_packages = {p.key for p in pkg_resources.working_set} |
| 239 | + return package_name in installed_packages |
0 commit comments