Skip to content

Commit 7dcde90

Browse files
authored
Merge pull request #340 from Scale3-Labs/release-2.3.10
Release 2.3.10
2 parents dd4bc1a + b5a13db commit 7dcde90

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

src/langtrace_python_sdk/instrumentation/crewai/patch.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ def traced_method(wrapped, instance, args, kwargs):
5151
)
5252
if result:
5353
span.set_status(Status(StatusCode.OK))
54-
span.end()
5554
return result
5655

5756
except Exception as err:
@@ -102,7 +101,6 @@ def traced_method(wrapped, instance, args, kwargs):
102101
span.set_attribute(
103102
f"crewai.crew.{attr}", str(getattr(result, attr))
104103
)
105-
span.end()
106104
return result
107105

108106
except Exception as err:
@@ -139,21 +137,27 @@ def run(self):
139137
for key, value in self.crew.items():
140138
key = f"crewai.crew.{key}"
141139
if value is not None:
142-
set_span_attribute(self.span, key, value)
140+
set_span_attribute(
141+
self.span, key, str(value) if isinstance(value, list) else value
142+
)
143143

144144
elif instance_name == "Agent":
145145
agent = self.set_agent_attributes()
146146
for key, value in agent.items():
147147
key = f"crewai.agent.{key}"
148148
if value is not None:
149-
set_span_attribute(self.span, key, value)
149+
set_span_attribute(
150+
self.span, key, str(value) if isinstance(value, list) else value
151+
)
150152

151153
elif instance_name == "Task":
152154
task = self.set_task_attributes()
153155
for key, value in task.items():
154156
key = f"crewai.task.{key}"
155157
if value is not None:
156-
set_span_attribute(self.span, key, value)
158+
set_span_attribute(
159+
self.span, key, str(value) if isinstance(value, list) else value
160+
)
157161

158162
def set_crew_attributes(self):
159163
for key, value in self.instance.__dict__.items():

src/langtrace_python_sdk/langtrace.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818
import sys
1919
from typing import Optional
20-
20+
import importlib.util
2121
from colorama import Fore
2222
from opentelemetry import trace
2323
from opentelemetry.instrumentation.sqlalchemy import SQLAlchemyInstrumentor
@@ -120,25 +120,25 @@ def init(
120120
all_instrumentations = {
121121
"openai": OpenAIInstrumentation(),
122122
"groq": GroqInstrumentation(),
123-
"pinecone": PineconeInstrumentation(),
124-
"llamaindex": LlamaindexInstrumentation(),
125-
"chroma": ChromaInstrumentation(),
123+
"pinecone-client": PineconeInstrumentation(),
124+
"llama-index": LlamaindexInstrumentation(),
125+
"chromadb": ChromaInstrumentation(),
126126
"embedchain": EmbedchainInstrumentation(),
127-
"qdrant": QdrantInstrumentation(),
127+
"qdrant-client": QdrantInstrumentation(),
128128
"langchain": LangchainInstrumentation(),
129-
"langchain_core": LangchainCoreInstrumentation(),
130-
"langchain_community": LangchainCommunityInstrumentation(),
129+
"langchain-core": LangchainCoreInstrumentation(),
130+
"langchain-community": LangchainCommunityInstrumentation(),
131131
"langgraph": LanggraphInstrumentation(),
132132
"anthropic": AnthropicInstrumentation(),
133133
"cohere": CohereInstrumentation(),
134-
"weaviate": WeaviateInstrumentation(),
134+
"weaviate-client": WeaviateInstrumentation(),
135135
"sqlalchemy": SQLAlchemyInstrumentor(),
136136
"ollama": OllamaInstrumentor(),
137-
"dspy": DspyInstrumentation(),
137+
"dspy-ai": DspyInstrumentation(),
138138
"crewai": CrewAIInstrumentation(),
139-
"vertexai": VertexAIInstrumentation(),
140-
"gemini": GeminiInstrumentation(),
141-
"mistral": MistralInstrumentation(),
139+
"google-cloud-aiplatform": VertexAIInstrumentation(),
140+
"google-generativeai": GeminiInstrumentation(),
141+
"mistralai": MistralInstrumentation(),
142142
}
143143

144144
init_instrumentations(disable_instrumentations, all_instrumentations)
@@ -171,8 +171,9 @@ def init_instrumentations(
171171
):
172172
if disable_instrumentations is None:
173173
for idx, (name, v) in enumerate(all_instrumentations.items()):
174+
if is_package_installed(name):
175+
v.instrument()
174176

175-
v.instrument()
176177
else:
177178

178179
validate_instrumentations(disable_instrumentations)
@@ -229,3 +230,7 @@ def validate_instrumentations(disable_instrumentations):
229230
raise ValueError(
230231
"Cannot specify both only and all_except in disable_instrumentations"
231232
)
233+
234+
235+
def is_package_installed(package_name):
236+
return importlib.util.find_spec(package_name) is not None
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.3.9"
1+
__version__ = "2.3.10"

0 commit comments

Comments
 (0)