openlit 1.33.10__py3-none-any.whl → 1.33.12__py3-none-any.whl
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/__helpers.py +125 -88
- openlit/__init__.py +38 -11
- openlit/instrumentation/ag2/__init__.py +19 -20
- openlit/instrumentation/ag2/ag2.py +134 -69
- openlit/instrumentation/ai21/__init__.py +22 -21
- openlit/instrumentation/ai21/ai21.py +82 -546
- openlit/instrumentation/ai21/async_ai21.py +82 -546
- openlit/instrumentation/ai21/utils.py +409 -0
- openlit/instrumentation/anthropic/__init__.py +16 -16
- openlit/instrumentation/anthropic/anthropic.py +61 -353
- openlit/instrumentation/anthropic/async_anthropic.py +62 -354
- openlit/instrumentation/anthropic/utils.py +251 -0
- openlit/instrumentation/assemblyai/__init__.py +2 -2
- openlit/instrumentation/assemblyai/assemblyai.py +3 -3
- openlit/instrumentation/astra/__init__.py +25 -25
- openlit/instrumentation/astra/astra.py +2 -2
- openlit/instrumentation/astra/async_astra.py +2 -2
- openlit/instrumentation/azure_ai_inference/__init__.py +5 -5
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +8 -8
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +8 -8
- openlit/instrumentation/bedrock/__init__.py +2 -2
- openlit/instrumentation/bedrock/bedrock.py +3 -3
- openlit/instrumentation/chroma/__init__.py +9 -9
- openlit/instrumentation/chroma/chroma.py +2 -2
- openlit/instrumentation/cohere/__init__.py +7 -7
- openlit/instrumentation/cohere/async_cohere.py +9 -9
- openlit/instrumentation/cohere/cohere.py +9 -9
- openlit/instrumentation/controlflow/__init__.py +4 -4
- openlit/instrumentation/controlflow/controlflow.py +2 -2
- openlit/instrumentation/crawl4ai/__init__.py +3 -3
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +2 -2
- openlit/instrumentation/crawl4ai/crawl4ai.py +2 -2
- openlit/instrumentation/crewai/__init__.py +3 -3
- openlit/instrumentation/crewai/crewai.py +2 -2
- openlit/instrumentation/dynamiq/__init__.py +5 -5
- openlit/instrumentation/dynamiq/dynamiq.py +2 -2
- openlit/instrumentation/elevenlabs/__init__.py +5 -5
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +3 -3
- openlit/instrumentation/elevenlabs/elevenlabs.py +3 -3
- openlit/instrumentation/embedchain/__init__.py +2 -2
- openlit/instrumentation/embedchain/embedchain.py +4 -4
- openlit/instrumentation/firecrawl/__init__.py +3 -3
- openlit/instrumentation/firecrawl/firecrawl.py +2 -2
- openlit/instrumentation/google_ai_studio/__init__.py +3 -3
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +3 -3
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +3 -3
- openlit/instrumentation/gpt4all/__init__.py +3 -3
- openlit/instrumentation/gpt4all/gpt4all.py +7 -7
- openlit/instrumentation/groq/__init__.py +3 -3
- openlit/instrumentation/groq/async_groq.py +5 -5
- openlit/instrumentation/groq/groq.py +5 -5
- openlit/instrumentation/haystack/__init__.py +2 -2
- openlit/instrumentation/haystack/haystack.py +2 -2
- openlit/instrumentation/julep/__init__.py +7 -7
- openlit/instrumentation/julep/async_julep.py +3 -3
- openlit/instrumentation/julep/julep.py +3 -3
- openlit/instrumentation/langchain/__init__.py +2 -2
- openlit/instrumentation/langchain/async_langchain.py +13 -9
- openlit/instrumentation/langchain/langchain.py +13 -8
- openlit/instrumentation/letta/__init__.py +7 -7
- openlit/instrumentation/letta/letta.py +5 -5
- openlit/instrumentation/litellm/__init__.py +5 -5
- openlit/instrumentation/litellm/async_litellm.py +8 -8
- openlit/instrumentation/litellm/litellm.py +8 -8
- openlit/instrumentation/llamaindex/__init__.py +2 -2
- openlit/instrumentation/llamaindex/llamaindex.py +2 -2
- openlit/instrumentation/mem0/__init__.py +2 -2
- openlit/instrumentation/mem0/mem0.py +2 -2
- openlit/instrumentation/milvus/__init__.py +2 -2
- openlit/instrumentation/milvus/milvus.py +2 -2
- openlit/instrumentation/mistral/__init__.py +7 -7
- openlit/instrumentation/mistral/async_mistral.py +10 -10
- openlit/instrumentation/mistral/mistral.py +10 -10
- openlit/instrumentation/multion/__init__.py +7 -7
- openlit/instrumentation/multion/async_multion.py +5 -5
- openlit/instrumentation/multion/multion.py +5 -5
- openlit/instrumentation/ollama/__init__.py +11 -9
- openlit/instrumentation/ollama/async_ollama.py +71 -465
- openlit/instrumentation/ollama/ollama.py +71 -465
- openlit/instrumentation/ollama/utils.py +332 -0
- openlit/instrumentation/openai/__init__.py +11 -11
- openlit/instrumentation/openai/async_openai.py +18 -18
- openlit/instrumentation/openai/openai.py +18 -18
- openlit/instrumentation/phidata/__init__.py +2 -2
- openlit/instrumentation/phidata/phidata.py +2 -2
- openlit/instrumentation/pinecone/__init__.py +6 -6
- openlit/instrumentation/pinecone/pinecone.py +2 -2
- openlit/instrumentation/premai/__init__.py +3 -3
- openlit/instrumentation/premai/premai.py +7 -7
- openlit/instrumentation/qdrant/__init__.py +2 -2
- openlit/instrumentation/qdrant/async_qdrant.py +2 -2
- openlit/instrumentation/qdrant/qdrant.py +2 -2
- openlit/instrumentation/reka/__init__.py +3 -3
- openlit/instrumentation/reka/async_reka.py +3 -3
- openlit/instrumentation/reka/reka.py +3 -3
- openlit/instrumentation/together/__init__.py +5 -5
- openlit/instrumentation/together/async_together.py +8 -8
- openlit/instrumentation/together/together.py +8 -8
- openlit/instrumentation/transformers/__init__.py +2 -2
- openlit/instrumentation/transformers/transformers.py +4 -4
- openlit/instrumentation/vertexai/__init__.py +9 -9
- openlit/instrumentation/vertexai/async_vertexai.py +4 -4
- openlit/instrumentation/vertexai/vertexai.py +4 -4
- openlit/instrumentation/vllm/__init__.py +2 -2
- openlit/instrumentation/vllm/vllm.py +3 -3
- openlit/otel/events.py +85 -0
- openlit/otel/tracing.py +3 -13
- openlit/semcov/__init__.py +13 -1
- {openlit-1.33.10.dist-info → openlit-1.33.12.dist-info}/METADATA +2 -2
- openlit-1.33.12.dist-info/RECORD +126 -0
- openlit-1.33.10.dist-info/RECORD +0 -122
- {openlit-1.33.10.dist-info → openlit-1.33.12.dist-info}/LICENSE +0 -0
- {openlit-1.33.10.dist-info → openlit-1.33.12.dist-info}/WHEEL +0 -0
@@ -96,7 +96,7 @@ class LangChainInstrumentor(BaseInstrumentor):
|
|
96
96
|
environment = kwargs.get("environment")
|
97
97
|
tracer = kwargs.get("tracer")
|
98
98
|
pricing_info = kwargs.get("pricing_info")
|
99
|
-
|
99
|
+
capture_message_content = kwargs.get("capture_message_content")
|
100
100
|
metrics = kwargs.get("metrics_dict")
|
101
101
|
disable_metrics = kwargs.get("disable_metrics")
|
102
102
|
version = importlib.metadata.version("langchain")
|
@@ -110,7 +110,7 @@ class LangChainInstrumentor(BaseInstrumentor):
|
|
110
110
|
wrap_package,
|
111
111
|
wrap_object,
|
112
112
|
wrapper(gen_ai_endpoint, version, environment, application_name,
|
113
|
-
tracer, pricing_info,
|
113
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
114
114
|
)
|
115
115
|
|
116
116
|
@staticmethod
|
@@ -41,7 +41,7 @@ def get_attribute_from_instance_or_kwargs(instance, attribute_name, default=-1):
|
|
41
41
|
return default
|
42
42
|
|
43
43
|
def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
44
|
-
tracer, pricing_info,
|
44
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
45
45
|
"""
|
46
46
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
47
47
|
|
@@ -55,7 +55,7 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
55
55
|
- application_name (str): Name of the Langchain application.
|
56
56
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
57
57
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
58
|
-
-
|
58
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
59
59
|
|
60
60
|
Returns:
|
61
61
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -114,7 +114,7 @@ def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
114
114
|
return wrapper
|
115
115
|
|
116
116
|
def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
|
117
|
-
pricing_info,
|
117
|
+
pricing_info, capture_message_content, metrics, disable_metrics):
|
118
118
|
"""
|
119
119
|
Creates a wrapper around Langchain hub operations for tracing and logging.
|
120
120
|
|
@@ -129,7 +129,7 @@ def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
|
|
129
129
|
- application_name (str): Name of the Langchain application.
|
130
130
|
- tracer (opentelemetry.trace.Tracer): The tracer for OpenTelemetry tracing.
|
131
131
|
- pricing_info (dict): Pricing information for the operation (not currently used).
|
132
|
-
-
|
132
|
+
- capture_message_content (bool): Indicates if the content of the response should be traced.
|
133
133
|
|
134
134
|
Returns:
|
135
135
|
- function: A new function that wraps the original hub operation call with added
|
@@ -189,7 +189,7 @@ def async_hub(gen_ai_endpoint, version, environment, application_name, tracer,
|
|
189
189
|
return wrapper
|
190
190
|
|
191
191
|
def async_chat(gen_ai_endpoint, version, environment, application_name,
|
192
|
-
tracer, pricing_info,
|
192
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
193
193
|
"""
|
194
194
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
195
195
|
|
@@ -202,7 +202,7 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
202
202
|
- application_name (str): Name of the Langchain application.
|
203
203
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
204
204
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
205
|
-
-
|
205
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
206
206
|
|
207
207
|
Returns:
|
208
208
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -287,6 +287,11 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
287
287
|
pricing_info, input_tokens, output_tokens
|
288
288
|
)
|
289
289
|
|
290
|
+
try:
|
291
|
+
llm_response = response.content
|
292
|
+
except AttributeError:
|
293
|
+
llm_response = response
|
294
|
+
|
290
295
|
# Set base span attribues (OTel Semconv)
|
291
296
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
292
297
|
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
@@ -328,18 +333,17 @@ def async_chat(gen_ai_endpoint, version, environment, application_name,
|
|
328
333
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
329
334
|
version)
|
330
335
|
|
331
|
-
if
|
336
|
+
if capture_message_content:
|
332
337
|
span.add_event(
|
333
338
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
334
339
|
attributes={
|
335
340
|
SemanticConvetion.GEN_AI_CONTENT_PROMPT: prompt,
|
336
341
|
},
|
337
342
|
)
|
338
|
-
completion_content = getattr(response, 'content', "")
|
339
343
|
span.add_event(
|
340
344
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
341
345
|
attributes={
|
342
|
-
SemanticConvetion.GEN_AI_CONTENT_COMPLETION:
|
346
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
|
343
347
|
},
|
344
348
|
)
|
345
349
|
|
@@ -41,7 +41,7 @@ def get_attribute_from_instance_or_kwargs(instance, attribute_name, default=-1):
|
|
41
41
|
return default
|
42
42
|
|
43
43
|
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
44
|
-
tracer, pricing_info,
|
44
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
45
45
|
"""
|
46
46
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
47
47
|
|
@@ -55,7 +55,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
55
55
|
- application_name (str): Name of the Langchain application.
|
56
56
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
57
57
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
58
|
-
-
|
58
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
59
59
|
|
60
60
|
Returns:
|
61
61
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -114,7 +114,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
114
114
|
return wrapper
|
115
115
|
|
116
116
|
def hub(gen_ai_endpoint, version, environment, application_name, tracer,
|
117
|
-
pricing_info,
|
117
|
+
pricing_info, capture_message_content, metrics, disable_metrics):
|
118
118
|
"""
|
119
119
|
Creates a wrapper around Langchain hub operations for tracing and logging.
|
120
120
|
|
@@ -129,7 +129,7 @@ def hub(gen_ai_endpoint, version, environment, application_name, tracer,
|
|
129
129
|
- application_name (str): Name of the Langchain application.
|
130
130
|
- tracer (opentelemetry.trace.Tracer): The tracer for OpenTelemetry tracing.
|
131
131
|
- pricing_info (dict): Pricing information for the operation (not currently used).
|
132
|
-
-
|
132
|
+
- capture_message_content (bool): Indicates if the content of the response should be traced.
|
133
133
|
|
134
134
|
Returns:
|
135
135
|
- function: A new function that wraps the original hub operation call with added
|
@@ -189,7 +189,7 @@ def hub(gen_ai_endpoint, version, environment, application_name, tracer,
|
|
189
189
|
return wrapper
|
190
190
|
|
191
191
|
def chat(gen_ai_endpoint, version, environment, application_name,
|
192
|
-
tracer, pricing_info,
|
192
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
193
193
|
"""
|
194
194
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
195
195
|
|
@@ -202,7 +202,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
202
202
|
- application_name (str): Name of the Langchain application.
|
203
203
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
204
204
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
205
|
-
-
|
205
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
206
206
|
|
207
207
|
Returns:
|
208
208
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -287,6 +287,11 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
287
287
|
pricing_info, input_tokens, output_tokens
|
288
288
|
)
|
289
289
|
|
290
|
+
try:
|
291
|
+
llm_response = response.content
|
292
|
+
except AttributeError:
|
293
|
+
llm_response = response
|
294
|
+
|
290
295
|
# Set base span attribues (OTel Semconv)
|
291
296
|
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
292
297
|
span.set_attribute(SemanticConvetion.GEN_AI_OPERATION,
|
@@ -328,7 +333,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
328
333
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
329
334
|
version)
|
330
335
|
|
331
|
-
if
|
336
|
+
if capture_message_content:
|
332
337
|
span.add_event(
|
333
338
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
334
339
|
attributes={
|
@@ -338,7 +343,7 @@ def chat(gen_ai_endpoint, version, environment, application_name,
|
|
338
343
|
span.add_event(
|
339
344
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
340
345
|
attributes={
|
341
|
-
SemanticConvetion.GEN_AI_CONTENT_COMPLETION:
|
346
|
+
SemanticConvetion.GEN_AI_CONTENT_COMPLETION: llm_response,
|
342
347
|
},
|
343
348
|
)
|
344
349
|
|
@@ -26,7 +26,7 @@ class LettaInstrumentor(BaseInstrumentor):
|
|
26
26
|
tracer = kwargs.get("tracer")
|
27
27
|
metrics = kwargs.get("metrics_dict")
|
28
28
|
pricing_info = kwargs.get("pricing_info", {})
|
29
|
-
|
29
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
30
30
|
disable_metrics = kwargs.get("disable_metrics")
|
31
31
|
version = importlib.metadata.version("letta")
|
32
32
|
|
@@ -34,42 +34,42 @@ class LettaInstrumentor(BaseInstrumentor):
|
|
34
34
|
"letta.client.client",
|
35
35
|
"LocalClient.create_agent",
|
36
36
|
create_agent("letta.create_agent", version, environment, application_name,
|
37
|
-
tracer, pricing_info,
|
37
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
38
38
|
)
|
39
39
|
|
40
40
|
wrap_function_wrapper(
|
41
41
|
"letta.client.client",
|
42
42
|
"LocalClient.get_agent",
|
43
43
|
create_agent("letta.get_agent", version, environment, application_name,
|
44
|
-
tracer, pricing_info,
|
44
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
45
45
|
)
|
46
46
|
|
47
47
|
wrap_function_wrapper(
|
48
48
|
"letta.client.client",
|
49
49
|
"LocalClient.send_message",
|
50
50
|
send_message("letta.send_message", version, environment, application_name,
|
51
|
-
tracer, pricing_info,
|
51
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
52
52
|
)
|
53
53
|
|
54
54
|
wrap_function_wrapper(
|
55
55
|
"letta.client.client",
|
56
56
|
"RESTClient.create_agent",
|
57
57
|
create_agent("letta.create_agent", version, environment, application_name,
|
58
|
-
tracer, pricing_info,
|
58
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
59
59
|
)
|
60
60
|
|
61
61
|
wrap_function_wrapper(
|
62
62
|
"letta.client.client",
|
63
63
|
"RESTClient.get_agent",
|
64
64
|
create_agent("letta.get_agent", version, environment, application_name,
|
65
|
-
tracer, pricing_info,
|
65
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
66
66
|
)
|
67
67
|
|
68
68
|
wrap_function_wrapper(
|
69
69
|
"letta.client.client",
|
70
70
|
"RESTClient.send_message",
|
71
71
|
send_message("letta.send_message", version, environment, application_name,
|
72
|
-
tracer, pricing_info,
|
72
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
73
73
|
)
|
74
74
|
|
75
75
|
def _uninstrument(self, **kwargs):
|
@@ -15,7 +15,7 @@ from openlit.semcov import SemanticConvetion
|
|
15
15
|
logger = logging.getLogger(__name__)
|
16
16
|
|
17
17
|
def create_agent(gen_ai_endpoint, version, environment, application_name,
|
18
|
-
tracer, pricing_info,
|
18
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
19
19
|
"""
|
20
20
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
21
21
|
|
@@ -26,7 +26,7 @@ def create_agent(gen_ai_endpoint, version, environment, application_name,
|
|
26
26
|
application_name: Name of the application using the Letta Agent.
|
27
27
|
tracer: OpenTelemetry tracer for creating spans.
|
28
28
|
pricing_info: Information used for calculating the cost of Letta usage.
|
29
|
-
|
29
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
30
30
|
|
31
31
|
Returns:
|
32
32
|
A function that wraps the chat completions method to add telemetry.
|
@@ -94,7 +94,7 @@ def create_agent(gen_ai_endpoint, version, environment, application_name,
|
|
94
94
|
return wrapper
|
95
95
|
|
96
96
|
def send_message(gen_ai_endpoint, version, environment, application_name,
|
97
|
-
tracer, pricing_info,
|
97
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
98
98
|
"""
|
99
99
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
100
100
|
|
@@ -105,7 +105,7 @@ def send_message(gen_ai_endpoint, version, environment, application_name,
|
|
105
105
|
application_name: Name of the application using the Letta Agent.
|
106
106
|
tracer: OpenTelemetry tracer for creating spans.
|
107
107
|
pricing_info: Information used for calculating the cost of Letta usage.
|
108
|
-
|
108
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
109
109
|
|
110
110
|
Returns:
|
111
111
|
A function that wraps the chat completions method to add telemetry.
|
@@ -158,7 +158,7 @@ def send_message(gen_ai_endpoint, version, environment, application_name,
|
|
158
158
|
span.set_attribute(SemanticConvetion.GEN_AI_USAGE_COST,
|
159
159
|
cost)
|
160
160
|
|
161
|
-
if
|
161
|
+
if capture_message_content:
|
162
162
|
span.add_event(
|
163
163
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
164
164
|
attributes={
|
@@ -29,7 +29,7 @@ class LiteLLMInstrumentor(BaseInstrumentor):
|
|
29
29
|
tracer = kwargs.get("tracer")
|
30
30
|
metrics = kwargs.get("metrics_dict")
|
31
31
|
pricing_info = kwargs.get("pricing_info", {})
|
32
|
-
|
32
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
33
33
|
disable_metrics = kwargs.get("disable_metrics")
|
34
34
|
version = importlib.metadata.version("litellm")
|
35
35
|
|
@@ -38,28 +38,28 @@ class LiteLLMInstrumentor(BaseInstrumentor):
|
|
38
38
|
"litellm",
|
39
39
|
"completion",
|
40
40
|
completion(version, environment, application_name,
|
41
|
-
tracer, pricing_info,
|
41
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
42
|
)
|
43
43
|
|
44
44
|
wrap_function_wrapper(
|
45
45
|
"litellm",
|
46
46
|
"acompletion",
|
47
47
|
acompletion(version, environment, application_name,
|
48
|
-
tracer, pricing_info,
|
48
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
49
49
|
)
|
50
50
|
|
51
51
|
wrap_function_wrapper(
|
52
52
|
"litellm",
|
53
53
|
"embedding",
|
54
54
|
embedding(version, environment, application_name,
|
55
|
-
tracer, pricing_info,
|
55
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
56
56
|
)
|
57
57
|
|
58
58
|
wrap_function_wrapper(
|
59
59
|
"litellm",
|
60
60
|
"aembedding",
|
61
61
|
aembedding(version, environment, application_name,
|
62
|
-
tracer, pricing_info,
|
62
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
63
63
|
)
|
64
64
|
|
65
65
|
def _uninstrument(self, **kwargs):
|
@@ -22,7 +22,7 @@ from openlit.semcov import SemanticConvetion
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
def acompletion(version, environment, application_name,
|
25
|
-
tracer, pricing_info,
|
25
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
26
26
|
"""
|
27
27
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
28
28
|
|
@@ -32,7 +32,7 @@ def acompletion(version, environment, application_name,
|
|
32
32
|
application_name: Name of the application using the LiteLLM SDK.
|
33
33
|
tracer: OpenTelemetry tracer for creating spans.
|
34
34
|
pricing_info: Information used for calculating the cost of LiteLLM usage.
|
35
|
-
|
35
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
36
36
|
|
37
37
|
Returns:
|
38
38
|
A function that wraps the chat completions method to add telemetry.
|
@@ -217,7 +217,7 @@ def acompletion(version, environment, application_name,
|
|
217
217
|
self._ttft)
|
218
218
|
self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
219
219
|
version)
|
220
|
-
if
|
220
|
+
if capture_message_content:
|
221
221
|
self._span.add_event(
|
222
222
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
223
223
|
attributes={
|
@@ -393,7 +393,7 @@ def acompletion(version, environment, application_name,
|
|
393
393
|
end_time - start_time)
|
394
394
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
395
395
|
version)
|
396
|
-
if
|
396
|
+
if capture_message_content:
|
397
397
|
span.add_event(
|
398
398
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
399
399
|
attributes={
|
@@ -404,7 +404,7 @@ def acompletion(version, environment, application_name,
|
|
404
404
|
for i in range(kwargs.get('n',1)):
|
405
405
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
406
406
|
[response_dict.get('choices')[i].get('finish_reason')])
|
407
|
-
if
|
407
|
+
if capture_message_content:
|
408
408
|
span.add_event(
|
409
409
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
410
410
|
attributes={
|
@@ -464,7 +464,7 @@ def acompletion(version, environment, application_name,
|
|
464
464
|
return wrapper
|
465
465
|
|
466
466
|
def aembedding(version, environment, application_name,
|
467
|
-
tracer, pricing_info,
|
467
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
468
468
|
"""
|
469
469
|
Generates a telemetry wrapper for embeddings to collect metrics.
|
470
470
|
|
@@ -474,7 +474,7 @@ def aembedding(version, environment, application_name,
|
|
474
474
|
application_name: Name of the application using the LiteLLM API.
|
475
475
|
tracer: OpenTelemetry tracer for creating spans.
|
476
476
|
pricing_info: Information used for calculating the cost of LiteLLM usage.
|
477
|
-
|
477
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
478
478
|
|
479
479
|
Returns:
|
480
480
|
A function that wraps the embeddings method to add telemetry.
|
@@ -548,7 +548,7 @@ def aembedding(version, environment, application_name,
|
|
548
548
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
549
549
|
version)
|
550
550
|
|
551
|
-
if
|
551
|
+
if capture_message_content:
|
552
552
|
span.add_event(
|
553
553
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
554
554
|
attributes={
|
@@ -22,7 +22,7 @@ from openlit.semcov import SemanticConvetion
|
|
22
22
|
logger = logging.getLogger(__name__)
|
23
23
|
|
24
24
|
def completion(version, environment, application_name,
|
25
|
-
tracer, pricing_info,
|
25
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
26
26
|
"""
|
27
27
|
Generates a telemetry wrapper for chat completions to collect metrics.
|
28
28
|
|
@@ -32,7 +32,7 @@ def completion(version, environment, application_name,
|
|
32
32
|
application_name: Name of the application using the LiteLLM SDK.
|
33
33
|
tracer: OpenTelemetry tracer for creating spans.
|
34
34
|
pricing_info: Information used for calculating the cost of LiteLLM usage.
|
35
|
-
|
35
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
36
36
|
|
37
37
|
Returns:
|
38
38
|
A function that wraps the chat completions method to add telemetry.
|
@@ -217,7 +217,7 @@ def completion(version, environment, application_name,
|
|
217
217
|
self._ttft)
|
218
218
|
self._span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
219
219
|
version)
|
220
|
-
if
|
220
|
+
if capture_message_content:
|
221
221
|
self._span.add_event(
|
222
222
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
223
223
|
attributes={
|
@@ -393,7 +393,7 @@ def completion(version, environment, application_name,
|
|
393
393
|
end_time - start_time)
|
394
394
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
395
395
|
version)
|
396
|
-
if
|
396
|
+
if capture_message_content:
|
397
397
|
span.add_event(
|
398
398
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
399
399
|
attributes={
|
@@ -404,7 +404,7 @@ def completion(version, environment, application_name,
|
|
404
404
|
for i in range(kwargs.get('n',1)):
|
405
405
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
406
406
|
[response_dict.get('choices')[i].get('finish_reason')])
|
407
|
-
if
|
407
|
+
if capture_message_content:
|
408
408
|
span.add_event(
|
409
409
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
410
410
|
attributes={
|
@@ -464,7 +464,7 @@ def completion(version, environment, application_name,
|
|
464
464
|
return wrapper
|
465
465
|
|
466
466
|
def embedding(version, environment, application_name,
|
467
|
-
tracer, pricing_info,
|
467
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
468
468
|
"""
|
469
469
|
Generates a telemetry wrapper for embeddings to collect metrics.
|
470
470
|
|
@@ -474,7 +474,7 @@ def embedding(version, environment, application_name,
|
|
474
474
|
application_name: Name of the application using the LiteLLM API.
|
475
475
|
tracer: OpenTelemetry tracer for creating spans.
|
476
476
|
pricing_info: Information used for calculating the cost of LiteLLM usage.
|
477
|
-
|
477
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
478
478
|
|
479
479
|
Returns:
|
480
480
|
A function that wraps the embeddings method to add telemetry.
|
@@ -548,7 +548,7 @@ def embedding(version, environment, application_name,
|
|
548
548
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
549
549
|
version)
|
550
550
|
|
551
|
-
if
|
551
|
+
if capture_message_content:
|
552
552
|
span.add_event(
|
553
553
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
554
554
|
attributes={
|
@@ -35,7 +35,7 @@ class LlamaIndexInstrumentor(BaseInstrumentor):
|
|
35
35
|
environment = kwargs.get("environment")
|
36
36
|
tracer = kwargs.get("tracer")
|
37
37
|
pricing_info = kwargs.get("pricing_info")
|
38
|
-
|
38
|
+
capture_message_content = kwargs.get("capture_message_content")
|
39
39
|
version = importlib.metadata.version("llama-index")
|
40
40
|
|
41
41
|
for wrapped_method in WRAPPED_METHODS:
|
@@ -47,7 +47,7 @@ class LlamaIndexInstrumentor(BaseInstrumentor):
|
|
47
47
|
wrap_package,
|
48
48
|
wrap_object,
|
49
49
|
wrapper(gen_ai_endpoint, version, environment, application_name,
|
50
|
-
tracer, pricing_info,
|
50
|
+
tracer, pricing_info, capture_message_content),
|
51
51
|
)
|
52
52
|
|
53
53
|
@staticmethod
|
@@ -13,7 +13,7 @@ from openlit.semcov import SemanticConvetion
|
|
13
13
|
logger = logging.getLogger(__name__)
|
14
14
|
|
15
15
|
def load_data(gen_ai_endpoint, version, environment, application_name,
|
16
|
-
tracer, pricing_info,
|
16
|
+
tracer, pricing_info, capture_message_content):
|
17
17
|
"""
|
18
18
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
19
19
|
|
@@ -27,7 +27,7 @@ def load_data(gen_ai_endpoint, version, environment, application_name,
|
|
27
27
|
- application_name (str): Name of the LlamaIndex application.
|
28
28
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
29
29
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
30
|
-
-
|
30
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
31
31
|
|
32
32
|
Returns:
|
33
33
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -59,7 +59,7 @@ class Mem0Instrumentor(BaseInstrumentor):
|
|
59
59
|
environment = kwargs.get("environment")
|
60
60
|
tracer = kwargs.get("tracer")
|
61
61
|
pricing_info = kwargs.get("pricing_info")
|
62
|
-
|
62
|
+
capture_message_content = kwargs.get("capture_message_content")
|
63
63
|
version = importlib.metadata.version("mem0ai")
|
64
64
|
|
65
65
|
for wrapped_method in WRAPPED_METHODS:
|
@@ -71,7 +71,7 @@ class Mem0Instrumentor(BaseInstrumentor):
|
|
71
71
|
wrap_package,
|
72
72
|
wrap_object,
|
73
73
|
wrapper(gen_ai_endpoint, version, environment, application_name,
|
74
|
-
tracer, pricing_info,
|
74
|
+
tracer, pricing_info, capture_message_content),
|
75
75
|
)
|
76
76
|
|
77
77
|
@staticmethod
|
@@ -13,7 +13,7 @@ from openlit.semcov import SemanticConvetion
|
|
13
13
|
logger = logging.getLogger(__name__)
|
14
14
|
|
15
15
|
def mem0_wrap(gen_ai_endpoint, version, environment, application_name,
|
16
|
-
tracer, pricing_info,
|
16
|
+
tracer, pricing_info, capture_message_content):
|
17
17
|
"""
|
18
18
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
19
19
|
|
@@ -27,7 +27,7 @@ def mem0_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
27
27
|
- application_name (str): Name of the mem0 application.
|
28
28
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
29
29
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
30
|
-
-
|
30
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
31
31
|
|
32
32
|
Returns:
|
33
33
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -72,7 +72,7 @@ class MilvusInstrumentor(BaseInstrumentor):
|
|
72
72
|
tracer = kwargs.get("tracer")
|
73
73
|
metrics = kwargs.get("metrics_dict")
|
74
74
|
pricing_info = kwargs.get("pricing_info")
|
75
|
-
|
75
|
+
capture_message_content = kwargs.get("capture_message_content")
|
76
76
|
disable_metrics = kwargs.get("disable_metrics")
|
77
77
|
version = importlib.metadata.version("pymilvus")
|
78
78
|
|
@@ -85,7 +85,7 @@ class MilvusInstrumentor(BaseInstrumentor):
|
|
85
85
|
wrap_package,
|
86
86
|
wrap_object,
|
87
87
|
wrapper(gen_ai_endpoint, version, environment, application_name,
|
88
|
-
tracer, pricing_info,
|
88
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
89
89
|
)
|
90
90
|
|
91
91
|
|
@@ -25,7 +25,7 @@ def object_count(obj):
|
|
25
25
|
return cnt
|
26
26
|
|
27
27
|
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
28
|
-
tracer, pricing_info,
|
28
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
29
29
|
"""
|
30
30
|
Creates a wrapper around a function call to trace and log its execution metrics.
|
31
31
|
|
@@ -39,7 +39,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
39
39
|
- application_name (str): Name of the Langchain application.
|
40
40
|
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
41
41
|
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
42
|
-
-
|
42
|
+
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
43
43
|
|
44
44
|
Returns:
|
45
45
|
- function: A higher-order function that takes a function 'wrapped' and returns
|
@@ -23,7 +23,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
23
23
|
tracer = kwargs.get("tracer")
|
24
24
|
metrics = kwargs.get("metrics_dict")
|
25
25
|
pricing_info = kwargs.get("pricing_info")
|
26
|
-
|
26
|
+
capture_message_content = kwargs.get("capture_message_content")
|
27
27
|
disable_metrics = kwargs.get("disable_metrics")
|
28
28
|
version = importlib.metadata.version("mistralai")
|
29
29
|
|
@@ -32,7 +32,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
32
32
|
"mistralai.chat",
|
33
33
|
"Chat.complete",
|
34
34
|
chat(version, environment, application_name,
|
35
|
-
tracer, pricing_info,
|
35
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
36
36
|
)
|
37
37
|
|
38
38
|
# sync
|
@@ -40,7 +40,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
40
40
|
"mistralai.chat",
|
41
41
|
"Chat.stream",
|
42
42
|
chat_stream(version, environment, application_name,
|
43
|
-
tracer, pricing_info,
|
43
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
44
44
|
)
|
45
45
|
|
46
46
|
# sync
|
@@ -48,7 +48,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
48
48
|
"mistralai.embeddings",
|
49
49
|
"Embeddings.create",
|
50
50
|
embeddings(version, environment, application_name,
|
51
|
-
tracer, pricing_info,
|
51
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
52
52
|
)
|
53
53
|
|
54
54
|
# Async
|
@@ -56,7 +56,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
56
56
|
"mistralai.chat",
|
57
57
|
"Chat.complete_async",
|
58
58
|
async_chat(version, environment, application_name,
|
59
|
-
tracer, pricing_info,
|
59
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
60
60
|
)
|
61
61
|
|
62
62
|
# Async
|
@@ -64,7 +64,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
64
64
|
"mistralai.chat",
|
65
65
|
"Chat.stream_async",
|
66
66
|
async_chat_stream(version, environment, application_name,
|
67
|
-
tracer, pricing_info,
|
67
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
68
68
|
)
|
69
69
|
|
70
70
|
#sync
|
@@ -72,7 +72,7 @@ class MistralInstrumentor(BaseInstrumentor):
|
|
72
72
|
"mistralai.embeddings",
|
73
73
|
"Embeddings.create_async",
|
74
74
|
async_embeddings(version, environment, application_name,
|
75
|
-
tracer, pricing_info,
|
75
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
76
76
|
)
|
77
77
|
|
78
78
|
@staticmethod
|