openlit 1.33.10__py3-none-any.whl → 1.33.11__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 +73 -0
- openlit/__init__.py +38 -11
- openlit/instrumentation/ag2/__init__.py +9 -10
- openlit/instrumentation/ag2/ag2.py +133 -68
- openlit/instrumentation/ai21/__init__.py +6 -5
- openlit/instrumentation/ai21/ai21.py +71 -534
- openlit/instrumentation/ai21/async_ai21.py +71 -534
- openlit/instrumentation/ai21/utils.py +407 -0
- openlit/instrumentation/anthropic/__init__.py +3 -3
- openlit/instrumentation/anthropic/anthropic.py +4 -4
- openlit/instrumentation/anthropic/async_anthropic.py +4 -4
- 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 +333 -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.11.dist-info}/METADATA +2 -2
- openlit-1.33.11.dist-info/RECORD +125 -0
- openlit-1.33.10.dist-info/RECORD +0 -122
- {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/LICENSE +0 -0
- {openlit-1.33.10.dist-info → openlit-1.33.11.dist-info}/WHEEL +0 -0
@@ -22,7 +22,7 @@ class AstraInstrumentor(BaseInstrumentor):
|
|
22
22
|
tracer = kwargs.get("tracer")
|
23
23
|
metrics = kwargs.get("metrics_dict")
|
24
24
|
pricing_info = kwargs.get("pricing_info")
|
25
|
-
|
25
|
+
capture_message_content = kwargs.get("capture_message_content")
|
26
26
|
disable_metrics = kwargs.get("disable_metrics")
|
27
27
|
version = importlib.metadata.version("astrapy")
|
28
28
|
|
@@ -31,73 +31,73 @@ class AstraInstrumentor(BaseInstrumentor):
|
|
31
31
|
"astrapy.database",
|
32
32
|
"Database.create_collection",
|
33
33
|
general_wrap("astra.create_collection", version, environment, application_name,
|
34
|
-
tracer, pricing_info,
|
34
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
35
35
|
)
|
36
36
|
wrap_function_wrapper(
|
37
37
|
"astrapy.database",
|
38
38
|
"Database.drop_collection",
|
39
39
|
general_wrap("astra.drop_collection", version, environment, application_name,
|
40
|
-
tracer, pricing_info,
|
40
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
41
41
|
)
|
42
42
|
wrap_function_wrapper(
|
43
43
|
"astrapy.collection",
|
44
44
|
"Collection.insert_one",
|
45
45
|
general_wrap("astra.insert_one", version, environment, application_name,
|
46
|
-
tracer, pricing_info,
|
46
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
47
|
)
|
48
48
|
wrap_function_wrapper(
|
49
49
|
"astrapy.collection",
|
50
50
|
"Collection.insert_many",
|
51
51
|
general_wrap("astra.insert_many", version, environment, application_name,
|
52
|
-
tracer, pricing_info,
|
52
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
53
53
|
)
|
54
54
|
wrap_function_wrapper(
|
55
55
|
"astrapy.collection",
|
56
56
|
"Collection.update_one",
|
57
57
|
general_wrap("astra.update_one", version, environment, application_name,
|
58
|
-
tracer, pricing_info,
|
58
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
59
59
|
)
|
60
60
|
wrap_function_wrapper(
|
61
61
|
"astrapy.collection",
|
62
62
|
"Collection.update_many",
|
63
63
|
general_wrap("astra.update_many", version, environment, application_name,
|
64
|
-
tracer, pricing_info,
|
64
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
65
65
|
)
|
66
66
|
wrap_function_wrapper(
|
67
67
|
"astrapy.collection",
|
68
68
|
"Collection.find_one_and_update",
|
69
69
|
general_wrap("astra.find_one_and_update", version, environment, application_name,
|
70
|
-
tracer, pricing_info,
|
70
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
71
71
|
)
|
72
72
|
wrap_function_wrapper(
|
73
73
|
"astrapy.collection",
|
74
74
|
"Collection.find",
|
75
75
|
general_wrap("astra.find", version, environment, application_name,
|
76
|
-
tracer, pricing_info,
|
76
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
77
77
|
)
|
78
78
|
wrap_function_wrapper(
|
79
79
|
"astrapy.collection",
|
80
80
|
"Collection.replace_one",
|
81
81
|
general_wrap("astra.replace_one", version, environment, application_name,
|
82
|
-
tracer, pricing_info,
|
82
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
83
83
|
)
|
84
84
|
wrap_function_wrapper(
|
85
85
|
"astrapy.collection",
|
86
86
|
"Collection.find_one_and_delete",
|
87
87
|
general_wrap("astra.find_one_and_delete", version, environment, application_name,
|
88
|
-
tracer, pricing_info,
|
88
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
89
89
|
)
|
90
90
|
wrap_function_wrapper(
|
91
91
|
"astrapy.collection",
|
92
92
|
"Collection.delete_one",
|
93
93
|
general_wrap("astra.delete_one", version, environment, application_name,
|
94
|
-
tracer, pricing_info,
|
94
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
95
95
|
)
|
96
96
|
wrap_function_wrapper(
|
97
97
|
"astrapy.collection",
|
98
98
|
"Collection.delete_many",
|
99
99
|
general_wrap("astra.delete_many", version, environment, application_name,
|
100
|
-
tracer, pricing_info,
|
100
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
101
101
|
)
|
102
102
|
|
103
103
|
# ASync
|
@@ -105,73 +105,73 @@ class AstraInstrumentor(BaseInstrumentor):
|
|
105
105
|
"astrapy.database",
|
106
106
|
"AsyncDatabase.create_collection",
|
107
107
|
general_wrap("astra.create_collection", version, environment, application_name,
|
108
|
-
tracer, pricing_info,
|
108
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
109
109
|
)
|
110
110
|
wrap_function_wrapper(
|
111
111
|
"astrapy.database",
|
112
112
|
"AsyncDatabase.drop_collection",
|
113
113
|
general_wrap("astra.drop_collection", version, environment, application_name,
|
114
|
-
tracer, pricing_info,
|
114
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
115
115
|
)
|
116
116
|
wrap_function_wrapper(
|
117
117
|
"astrapy.collection",
|
118
118
|
"AsyncCollection.insert_one",
|
119
119
|
general_wrap("astra.insert_one", version, environment, application_name,
|
120
|
-
tracer, pricing_info,
|
120
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
121
121
|
)
|
122
122
|
wrap_function_wrapper(
|
123
123
|
"astrapy.collection",
|
124
124
|
"AsyncCollection.insert_many",
|
125
125
|
general_wrap("astra.insert_many", version, environment, application_name,
|
126
|
-
tracer, pricing_info,
|
126
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
127
127
|
)
|
128
128
|
wrap_function_wrapper(
|
129
129
|
"astrapy.collection",
|
130
130
|
"AsyncCollection.update_one",
|
131
131
|
general_wrap("astra.update_one", version, environment, application_name,
|
132
|
-
tracer, pricing_info,
|
132
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
133
133
|
)
|
134
134
|
wrap_function_wrapper(
|
135
135
|
"astrapy.collection",
|
136
136
|
"AsyncCollection.update_many",
|
137
137
|
general_wrap("astra.update_many", version, environment, application_name,
|
138
|
-
tracer, pricing_info,
|
138
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
139
139
|
)
|
140
140
|
wrap_function_wrapper(
|
141
141
|
"astrapy.collection",
|
142
142
|
"AsyncCollection.find_one_and_update",
|
143
143
|
general_wrap("astra.find_one_and_update", version, environment, application_name,
|
144
|
-
tracer, pricing_info,
|
144
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
145
145
|
)
|
146
146
|
wrap_function_wrapper(
|
147
147
|
"astrapy.collection",
|
148
148
|
"AsyncCollection.find",
|
149
149
|
general_wrap("astra.find", version, environment, application_name,
|
150
|
-
tracer, pricing_info,
|
150
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
151
151
|
)
|
152
152
|
wrap_function_wrapper(
|
153
153
|
"astrapy.collection",
|
154
154
|
"AsyncCollection.replace_one",
|
155
155
|
general_wrap("astra.replace_one", version, environment, application_name,
|
156
|
-
tracer, pricing_info,
|
156
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
157
157
|
)
|
158
158
|
wrap_function_wrapper(
|
159
159
|
"astrapy.collection",
|
160
160
|
"AsyncCollection.find_one_and_delete",
|
161
161
|
general_wrap("astra.find_one_and_delete", version, environment, application_name,
|
162
|
-
tracer, pricing_info,
|
162
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
163
163
|
)
|
164
164
|
wrap_function_wrapper(
|
165
165
|
"astrapy.collection",
|
166
166
|
"AsyncCollection.delete_one",
|
167
167
|
general_wrap("astra.delete_one", version, environment, application_name,
|
168
|
-
tracer, pricing_info,
|
168
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
169
169
|
)
|
170
170
|
wrap_function_wrapper(
|
171
171
|
"astrapy.collection",
|
172
172
|
"AsyncCollection.delete_many",
|
173
173
|
general_wrap("astra.delete_many", version, environment, application_name,
|
174
|
-
tracer, pricing_info,
|
174
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
175
175
|
)
|
176
176
|
|
177
177
|
@staticmethod
|
@@ -20,7 +20,7 @@ def object_count(obj):
|
|
20
20
|
return len(obj) if obj else None
|
21
21
|
|
22
22
|
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
23
|
-
tracer, pricing_info,
|
23
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
24
24
|
"""
|
25
25
|
Wraps a AstraDB operation to trace and log its execution metrics.
|
26
26
|
|
@@ -37,7 +37,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
37
37
|
- application_name (str): The name of the application performing the AstraDB operation.
|
38
38
|
- tracer (opentelemetry.trace.Tracer): An object used for OpenTelemetry tracing.
|
39
39
|
- pricing_info (dict): Information about pricing, not used in current implementation.
|
40
|
-
-
|
40
|
+
- capture_message_content (bool): A flag indicating whether the content of responses should be traced.
|
41
41
|
|
42
42
|
Returns:
|
43
43
|
- function: A decorator function that, when applied, wraps the target function with
|
@@ -20,7 +20,7 @@ def object_count(obj):
|
|
20
20
|
return len(obj) if obj else None
|
21
21
|
|
22
22
|
def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
23
|
-
tracer, pricing_info,
|
23
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
24
24
|
"""
|
25
25
|
Wraps a AstraDB operation to trace and log its execution metrics.
|
26
26
|
|
@@ -37,7 +37,7 @@ def general_wrap(gen_ai_endpoint, version, environment, application_name,
|
|
37
37
|
- application_name (str): The name of the application performing the AstraDB operation.
|
38
38
|
- tracer (opentelemetry.trace.Tracer): An object used for OpenTelemetry tracing.
|
39
39
|
- pricing_info (dict): Information about pricing, not used in current implementation.
|
40
|
-
-
|
40
|
+
- capture_message_content (bool): A flag indicating whether the content of responses should be traced.
|
41
41
|
|
42
42
|
Returns:
|
43
43
|
- function: A decorator function that, when applied, wraps the target function with
|
@@ -30,7 +30,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
30
30
|
tracer = kwargs.get("tracer")
|
31
31
|
metrics = kwargs.get("metrics_dict")
|
32
32
|
pricing_info = kwargs.get("pricing_info", {})
|
33
|
-
|
33
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
34
34
|
disable_metrics = kwargs.get("disable_metrics")
|
35
35
|
version = importlib.metadata.version("azure-ai-inference")
|
36
36
|
|
@@ -39,7 +39,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
39
39
|
"azure.ai.inference",
|
40
40
|
"ChatCompletionsClient.complete",
|
41
41
|
complete(version, environment, application_name,
|
42
|
-
tracer, pricing_info,
|
42
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
43
43
|
)
|
44
44
|
|
45
45
|
# sync embedding
|
@@ -47,7 +47,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
47
47
|
"azure.ai.inference",
|
48
48
|
"EmbeddingsClient.embed",
|
49
49
|
embedding(version, environment, application_name,
|
50
|
-
tracer, pricing_info,
|
50
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
51
51
|
)
|
52
52
|
|
53
53
|
# async generate
|
@@ -55,7 +55,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
55
55
|
"azure.ai.inference.aio",
|
56
56
|
"ChatCompletionsClient.complete",
|
57
57
|
async_complete(version, environment, application_name,
|
58
|
-
tracer, pricing_info,
|
58
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
59
59
|
)
|
60
60
|
|
61
61
|
# async embedding
|
@@ -63,7 +63,7 @@ class AzureAIInferenceInstrumentor(BaseInstrumentor):
|
|
63
63
|
"azure.ai.inference.aio",
|
64
64
|
"EmbeddingsClient.embed",
|
65
65
|
async_embedding(version, environment, application_name,
|
66
|
-
tracer, pricing_info,
|
66
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
67
67
|
)
|
68
68
|
|
69
69
|
def _uninstrument(self, **kwargs):
|
@@ -23,7 +23,7 @@ from openlit.semcov import SemanticConvetion
|
|
23
23
|
logger = logging.getLogger(__name__)
|
24
24
|
|
25
25
|
def async_complete(version, environment, application_name,
|
26
|
-
tracer, pricing_info,
|
26
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
27
27
|
"""
|
28
28
|
Generates a telemetry wrapper for chat to collect metrics.
|
29
29
|
|
@@ -33,7 +33,7 @@ def async_complete(version, environment, application_name,
|
|
33
33
|
application_name: Name of the application using the Azure AI Inference API.
|
34
34
|
tracer: OpenTelemetry tracer for creating spans.
|
35
35
|
pricing_info: Information used for calculating the cost of Azure AI Inference usage.
|
36
|
-
|
36
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
37
37
|
|
38
38
|
Returns:
|
39
39
|
A function that wraps the chat method to add telemetry.
|
@@ -217,7 +217,7 @@ def async_complete(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={
|
@@ -388,7 +388,7 @@ def async_complete(version, environment, application_name,
|
|
388
388
|
end_time - start_time)
|
389
389
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
390
390
|
version)
|
391
|
-
if
|
391
|
+
if capture_message_content:
|
392
392
|
span.add_event(
|
393
393
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
394
394
|
attributes={
|
@@ -399,7 +399,7 @@ def async_complete(version, environment, application_name,
|
|
399
399
|
for i in range(kwargs.get('n',1)):
|
400
400
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
401
401
|
[response_dict.get('choices')[i].get('finish_reason')])
|
402
|
-
if
|
402
|
+
if capture_message_content:
|
403
403
|
span.add_event(
|
404
404
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
405
405
|
attributes={
|
@@ -459,7 +459,7 @@ def async_complete(version, environment, application_name,
|
|
459
459
|
return wrapper
|
460
460
|
|
461
461
|
def async_embedding(version, environment, application_name,
|
462
|
-
tracer, pricing_info,
|
462
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
463
463
|
"""
|
464
464
|
Generates a telemetry wrapper for embeddings to collect metrics.
|
465
465
|
|
@@ -469,7 +469,7 @@ def async_embedding(version, environment, application_name,
|
|
469
469
|
application_name: Name of the application using the Azure Inference API.
|
470
470
|
tracer: OpenTelemetry tracer for creating spans.
|
471
471
|
pricing_info: Information used for calculating the cost of Azure Inference usage.
|
472
|
-
|
472
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
473
473
|
|
474
474
|
Returns:
|
475
475
|
A function that wraps the embeddings method to add telemetry.
|
@@ -541,7 +541,7 @@ def async_embedding(version, environment, application_name,
|
|
541
541
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
542
542
|
version)
|
543
543
|
|
544
|
-
if
|
544
|
+
if capture_message_content:
|
545
545
|
span.add_event(
|
546
546
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
547
547
|
attributes={
|
@@ -23,7 +23,7 @@ from openlit.semcov import SemanticConvetion
|
|
23
23
|
logger = logging.getLogger(__name__)
|
24
24
|
|
25
25
|
def complete(version, environment, application_name,
|
26
|
-
tracer, pricing_info,
|
26
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
27
27
|
"""
|
28
28
|
Generates a telemetry wrapper for chat to collect metrics.
|
29
29
|
|
@@ -33,7 +33,7 @@ def complete(version, environment, application_name,
|
|
33
33
|
application_name: Name of the application using the Azure AI Inference API.
|
34
34
|
tracer: OpenTelemetry tracer for creating spans.
|
35
35
|
pricing_info: Information used for calculating the cost of Azure AI Inference usage.
|
36
|
-
|
36
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
37
37
|
|
38
38
|
Returns:
|
39
39
|
A function that wraps the chat method to add telemetry.
|
@@ -217,7 +217,7 @@ def complete(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={
|
@@ -388,7 +388,7 @@ def complete(version, environment, application_name,
|
|
388
388
|
end_time - start_time)
|
389
389
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
390
390
|
version)
|
391
|
-
if
|
391
|
+
if capture_message_content:
|
392
392
|
span.add_event(
|
393
393
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
394
394
|
attributes={
|
@@ -399,7 +399,7 @@ def complete(version, environment, application_name,
|
|
399
399
|
for i in range(kwargs.get('n',1)):
|
400
400
|
span.set_attribute(SemanticConvetion.GEN_AI_RESPONSE_FINISH_REASON,
|
401
401
|
[response_dict.get('choices')[i].get('finish_reason')])
|
402
|
-
if
|
402
|
+
if capture_message_content:
|
403
403
|
span.add_event(
|
404
404
|
name=SemanticConvetion.GEN_AI_CONTENT_COMPLETION_EVENT,
|
405
405
|
attributes={
|
@@ -459,7 +459,7 @@ def complete(version, environment, application_name,
|
|
459
459
|
return wrapper
|
460
460
|
|
461
461
|
def embedding(version, environment, application_name,
|
462
|
-
tracer, pricing_info,
|
462
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
463
463
|
"""
|
464
464
|
Generates a telemetry wrapper for embeddings to collect metrics.
|
465
465
|
|
@@ -469,7 +469,7 @@ def embedding(version, environment, application_name,
|
|
469
469
|
application_name: Name of the application using the Azure Inference API.
|
470
470
|
tracer: OpenTelemetry tracer for creating spans.
|
471
471
|
pricing_info: Information used for calculating the cost of Azure Inference usage.
|
472
|
-
|
472
|
+
capture_message_content: Flag indicating whether to trace the actual content.
|
473
473
|
|
474
474
|
Returns:
|
475
475
|
A function that wraps the embeddings method to add telemetry.
|
@@ -541,7 +541,7 @@ def embedding(version, environment, application_name,
|
|
541
541
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
542
542
|
version)
|
543
543
|
|
544
|
-
if
|
544
|
+
if capture_message_content:
|
545
545
|
span.add_event(
|
546
546
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
547
547
|
attributes={
|
@@ -24,7 +24,7 @@ class BedrockInstrumentor(BaseInstrumentor):
|
|
24
24
|
tracer = kwargs.get("tracer")
|
25
25
|
metrics = kwargs.get("metrics_dict")
|
26
26
|
pricing_info = kwargs.get("pricing_info", {})
|
27
|
-
|
27
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
28
28
|
disable_metrics = kwargs.get("disable_metrics")
|
29
29
|
version = importlib.metadata.version("boto3")
|
30
30
|
|
@@ -33,7 +33,7 @@ class BedrockInstrumentor(BaseInstrumentor):
|
|
33
33
|
"botocore.client",
|
34
34
|
"ClientCreator.create_client",
|
35
35
|
converse(version, environment, application_name,
|
36
|
-
tracer, pricing_info,
|
36
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
37
37
|
)
|
38
38
|
|
39
39
|
def _uninstrument(self, **kwargs):
|
@@ -53,7 +53,7 @@ class CustomStreamWrapper(StreamingBody):
|
|
53
53
|
return data_chunk
|
54
54
|
|
55
55
|
def converse(version, environment, application_name, tracer,
|
56
|
-
pricing_info,
|
56
|
+
pricing_info, capture_message_content, metrics, disable_metrics):
|
57
57
|
"""
|
58
58
|
Generates a telemetry wrapper for messages to collect metrics.
|
59
59
|
|
@@ -64,7 +64,7 @@ def converse(version, environment, application_name, tracer,
|
|
64
64
|
application_name: Name of the application using the Bedrock API.
|
65
65
|
tracer: OpenTelemetry tracer for creating spans.
|
66
66
|
pricing_info: Information for calculating Bedrock usage cost.
|
67
|
-
|
67
|
+
capture_message_content: Whether to trace the actual content.
|
68
68
|
metrics: Metrics collector.
|
69
69
|
disable_metrics: Flag to toggle metrics collection.
|
70
70
|
Returns:
|
@@ -194,7 +194,7 @@ def converse(version, environment, application_name, tracer,
|
|
194
194
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
195
195
|
version)
|
196
196
|
|
197
|
-
if
|
197
|
+
if capture_message_content:
|
198
198
|
span.add_event(
|
199
199
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
200
200
|
attributes={
|
@@ -21,7 +21,7 @@ class ChromaInstrumentor(BaseInstrumentor):
|
|
21
21
|
tracer = kwargs.get("tracer")
|
22
22
|
metrics = kwargs.get("metrics_dict")
|
23
23
|
pricing_info = kwargs.get("pricing_info")
|
24
|
-
|
24
|
+
capture_message_content = kwargs.get("capture_message_content")
|
25
25
|
disable_metrics = kwargs.get("disable_metrics")
|
26
26
|
version = importlib.metadata.version("chromadb")
|
27
27
|
|
@@ -29,55 +29,55 @@ class ChromaInstrumentor(BaseInstrumentor):
|
|
29
29
|
"chromadb.db",
|
30
30
|
"DB.create_collection",
|
31
31
|
general_wrap("chroma.create_collection", version, environment, application_name,
|
32
|
-
tracer, pricing_info,
|
32
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
33
33
|
)
|
34
34
|
|
35
35
|
wrap_function_wrapper(
|
36
36
|
"chromadb",
|
37
37
|
"Collection.add",
|
38
38
|
general_wrap("chroma.add", version, environment, application_name,
|
39
|
-
tracer, pricing_info,
|
39
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
40
40
|
)
|
41
41
|
|
42
42
|
wrap_function_wrapper(
|
43
43
|
"chromadb",
|
44
44
|
"Collection.get",
|
45
45
|
general_wrap("chroma.get", version, environment, application_name,
|
46
|
-
tracer, pricing_info,
|
46
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
47
|
)
|
48
48
|
|
49
49
|
wrap_function_wrapper(
|
50
50
|
"chromadb",
|
51
51
|
"Collection.peek",
|
52
52
|
general_wrap("chroma.peek", version, environment, application_name,
|
53
|
-
tracer, pricing_info,
|
53
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
54
54
|
)
|
55
55
|
|
56
56
|
wrap_function_wrapper(
|
57
57
|
"chromadb",
|
58
58
|
"Collection.query",
|
59
59
|
general_wrap("chroma.query", version, environment, application_name,
|
60
|
-
tracer, pricing_info,
|
60
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
61
61
|
)
|
62
62
|
|
63
63
|
wrap_function_wrapper(
|
64
64
|
"chromadb",
|
65
65
|
"Collection.update",
|
66
66
|
general_wrap("chroma.update", version, environment, application_name,
|
67
|
-
tracer, pricing_info,
|
67
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
68
68
|
)
|
69
69
|
|
70
70
|
wrap_function_wrapper(
|
71
71
|
"chromadb",
|
72
72
|
"Collection.upsert",
|
73
73
|
general_wrap("chroma.upsert", version, environment, application_name,
|
74
|
-
tracer, pricing_info,
|
74
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
75
75
|
)
|
76
76
|
wrap_function_wrapper(
|
77
77
|
"chromadb",
|
78
78
|
"Collection.delete",
|
79
79
|
general_wrap("chroma.delete", version, environment, application_name,
|
80
|
-
tracer, pricing_info,
|
80
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
81
81
|
)
|
82
82
|
|
83
83
|
|
@@ -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 CohereInstrumentor(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("cohere")
|
29
29
|
|
@@ -32,19 +32,19 @@ class CohereInstrumentor(BaseInstrumentor):
|
|
32
32
|
"cohere.client_v2",
|
33
33
|
"ClientV2.chat",
|
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
|
wrap_function_wrapper(
|
38
38
|
"cohere.client_v2",
|
39
39
|
"ClientV2.chat_stream",
|
40
40
|
chat_stream(version, environment, application_name,
|
41
|
-
tracer, pricing_info,
|
41
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
42
42
|
)
|
43
43
|
wrap_function_wrapper(
|
44
44
|
"cohere.client_v2",
|
45
45
|
"ClientV2.embed",
|
46
46
|
embed(version, environment, application_name,
|
47
|
-
tracer, pricing_info,
|
47
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
48
48
|
)
|
49
49
|
|
50
50
|
# Async Client
|
@@ -52,21 +52,21 @@ class CohereInstrumentor(BaseInstrumentor):
|
|
52
52
|
"cohere.client_v2",
|
53
53
|
"AsyncClientV2.chat",
|
54
54
|
async_chat(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
|
"cohere.client_v2",
|
60
60
|
"AsyncClientV2.chat_stream",
|
61
61
|
async_chat_stream(version, environment, application_name,
|
62
|
-
tracer, pricing_info,
|
62
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
63
63
|
)
|
64
64
|
|
65
65
|
wrap_function_wrapper(
|
66
66
|
"cohere.client_v2",
|
67
67
|
"AsyncClientV2.embed",
|
68
68
|
async_embed(version, environment, application_name,
|
69
|
-
tracer, pricing_info,
|
69
|
+
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
70
70
|
)
|
71
71
|
|
72
72
|
@staticmethod
|