openlit 1.34.29__py3-none-any.whl → 1.34.31__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 +235 -86
- openlit/__init__.py +16 -13
- openlit/_instrumentors.py +2 -1
- openlit/evals/all.py +50 -21
- openlit/evals/bias_detection.py +47 -20
- openlit/evals/hallucination.py +53 -22
- openlit/evals/toxicity.py +50 -21
- openlit/evals/utils.py +54 -30
- openlit/guard/all.py +61 -19
- openlit/guard/prompt_injection.py +34 -14
- openlit/guard/restrict_topic.py +46 -15
- openlit/guard/sensitive_topic.py +34 -14
- openlit/guard/utils.py +58 -22
- openlit/instrumentation/ag2/__init__.py +24 -8
- openlit/instrumentation/ag2/ag2.py +34 -13
- openlit/instrumentation/ag2/async_ag2.py +34 -13
- openlit/instrumentation/ag2/utils.py +133 -30
- openlit/instrumentation/ai21/__init__.py +43 -14
- openlit/instrumentation/ai21/ai21.py +47 -21
- openlit/instrumentation/ai21/async_ai21.py +47 -21
- openlit/instrumentation/ai21/utils.py +299 -78
- openlit/instrumentation/anthropic/__init__.py +21 -4
- openlit/instrumentation/anthropic/anthropic.py +28 -17
- openlit/instrumentation/anthropic/async_anthropic.py +28 -17
- openlit/instrumentation/anthropic/utils.py +145 -35
- openlit/instrumentation/assemblyai/__init__.py +11 -2
- openlit/instrumentation/assemblyai/assemblyai.py +15 -4
- openlit/instrumentation/assemblyai/utils.py +120 -25
- openlit/instrumentation/astra/__init__.py +43 -10
- openlit/instrumentation/astra/astra.py +28 -5
- openlit/instrumentation/astra/async_astra.py +28 -5
- openlit/instrumentation/astra/utils.py +151 -55
- openlit/instrumentation/azure_ai_inference/__init__.py +43 -10
- openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +53 -21
- openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +53 -21
- openlit/instrumentation/azure_ai_inference/utils.py +307 -83
- openlit/instrumentation/bedrock/__init__.py +21 -4
- openlit/instrumentation/bedrock/bedrock.py +63 -25
- openlit/instrumentation/bedrock/utils.py +139 -30
- openlit/instrumentation/chroma/__init__.py +89 -16
- openlit/instrumentation/chroma/chroma.py +28 -6
- openlit/instrumentation/chroma/utils.py +167 -51
- openlit/instrumentation/cohere/__init__.py +63 -18
- openlit/instrumentation/cohere/async_cohere.py +63 -24
- openlit/instrumentation/cohere/cohere.py +63 -24
- openlit/instrumentation/cohere/utils.py +286 -73
- openlit/instrumentation/controlflow/__init__.py +35 -9
- openlit/instrumentation/controlflow/controlflow.py +66 -33
- openlit/instrumentation/crawl4ai/__init__.py +25 -10
- openlit/instrumentation/crawl4ai/async_crawl4ai.py +78 -31
- openlit/instrumentation/crawl4ai/crawl4ai.py +78 -31
- openlit/instrumentation/crewai/__init__.py +111 -24
- openlit/instrumentation/crewai/async_crewai.py +114 -0
- openlit/instrumentation/crewai/crewai.py +104 -131
- openlit/instrumentation/crewai/utils.py +615 -0
- openlit/instrumentation/dynamiq/__init__.py +46 -12
- openlit/instrumentation/dynamiq/dynamiq.py +74 -33
- openlit/instrumentation/elevenlabs/__init__.py +23 -4
- openlit/instrumentation/elevenlabs/async_elevenlabs.py +16 -4
- openlit/instrumentation/elevenlabs/elevenlabs.py +16 -4
- openlit/instrumentation/elevenlabs/utils.py +128 -25
- openlit/instrumentation/embedchain/__init__.py +11 -2
- openlit/instrumentation/embedchain/embedchain.py +68 -35
- openlit/instrumentation/firecrawl/__init__.py +24 -7
- openlit/instrumentation/firecrawl/firecrawl.py +46 -20
- openlit/instrumentation/google_ai_studio/__init__.py +45 -10
- openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +67 -44
- openlit/instrumentation/google_ai_studio/google_ai_studio.py +67 -44
- openlit/instrumentation/google_ai_studio/utils.py +180 -67
- openlit/instrumentation/gpt4all/__init__.py +22 -7
- openlit/instrumentation/gpt4all/gpt4all.py +67 -29
- openlit/instrumentation/gpt4all/utils.py +285 -61
- openlit/instrumentation/gpu/__init__.py +128 -47
- openlit/instrumentation/groq/__init__.py +21 -4
- openlit/instrumentation/groq/async_groq.py +33 -21
- openlit/instrumentation/groq/groq.py +33 -21
- openlit/instrumentation/groq/utils.py +192 -55
- openlit/instrumentation/haystack/__init__.py +70 -24
- openlit/instrumentation/haystack/async_haystack.py +28 -6
- openlit/instrumentation/haystack/haystack.py +28 -6
- openlit/instrumentation/haystack/utils.py +196 -74
- openlit/instrumentation/julep/__init__.py +69 -19
- openlit/instrumentation/julep/async_julep.py +53 -27
- openlit/instrumentation/julep/julep.py +53 -28
- openlit/instrumentation/langchain/__init__.py +74 -63
- openlit/instrumentation/langchain/callback_handler.py +1100 -0
- openlit/instrumentation/langchain_community/__init__.py +13 -2
- openlit/instrumentation/langchain_community/async_langchain_community.py +23 -5
- openlit/instrumentation/langchain_community/langchain_community.py +23 -5
- openlit/instrumentation/langchain_community/utils.py +35 -9
- openlit/instrumentation/letta/__init__.py +68 -15
- openlit/instrumentation/letta/letta.py +99 -54
- openlit/instrumentation/litellm/__init__.py +43 -14
- openlit/instrumentation/litellm/async_litellm.py +51 -26
- openlit/instrumentation/litellm/litellm.py +51 -26
- openlit/instrumentation/litellm/utils.py +312 -101
- openlit/instrumentation/llamaindex/__init__.py +267 -90
- openlit/instrumentation/llamaindex/async_llamaindex.py +28 -6
- openlit/instrumentation/llamaindex/llamaindex.py +28 -6
- openlit/instrumentation/llamaindex/utils.py +204 -91
- openlit/instrumentation/mem0/__init__.py +11 -2
- openlit/instrumentation/mem0/mem0.py +50 -29
- openlit/instrumentation/milvus/__init__.py +10 -2
- openlit/instrumentation/milvus/milvus.py +31 -6
- openlit/instrumentation/milvus/utils.py +166 -67
- openlit/instrumentation/mistral/__init__.py +63 -18
- openlit/instrumentation/mistral/async_mistral.py +63 -24
- openlit/instrumentation/mistral/mistral.py +63 -24
- openlit/instrumentation/mistral/utils.py +277 -69
- openlit/instrumentation/multion/__init__.py +69 -19
- openlit/instrumentation/multion/async_multion.py +57 -26
- openlit/instrumentation/multion/multion.py +57 -26
- openlit/instrumentation/ollama/__init__.py +39 -18
- openlit/instrumentation/ollama/async_ollama.py +57 -26
- openlit/instrumentation/ollama/ollama.py +57 -26
- openlit/instrumentation/ollama/utils.py +226 -50
- openlit/instrumentation/openai/__init__.py +156 -32
- openlit/instrumentation/openai/async_openai.py +147 -67
- openlit/instrumentation/openai/openai.py +150 -67
- openlit/instrumentation/openai/utils.py +660 -186
- openlit/instrumentation/openai_agents/__init__.py +6 -2
- openlit/instrumentation/openai_agents/processor.py +409 -537
- openlit/instrumentation/phidata/__init__.py +13 -5
- openlit/instrumentation/phidata/phidata.py +67 -32
- openlit/instrumentation/pinecone/__init__.py +48 -9
- openlit/instrumentation/pinecone/async_pinecone.py +27 -5
- openlit/instrumentation/pinecone/pinecone.py +27 -5
- openlit/instrumentation/pinecone/utils.py +153 -47
- openlit/instrumentation/premai/__init__.py +22 -7
- openlit/instrumentation/premai/premai.py +51 -26
- openlit/instrumentation/premai/utils.py +246 -59
- openlit/instrumentation/pydantic_ai/__init__.py +49 -22
- openlit/instrumentation/pydantic_ai/pydantic_ai.py +69 -16
- openlit/instrumentation/pydantic_ai/utils.py +89 -24
- openlit/instrumentation/qdrant/__init__.py +19 -4
- openlit/instrumentation/qdrant/async_qdrant.py +33 -7
- openlit/instrumentation/qdrant/qdrant.py +33 -7
- openlit/instrumentation/qdrant/utils.py +228 -93
- openlit/instrumentation/reka/__init__.py +23 -10
- openlit/instrumentation/reka/async_reka.py +17 -11
- openlit/instrumentation/reka/reka.py +17 -11
- openlit/instrumentation/reka/utils.py +138 -36
- openlit/instrumentation/together/__init__.py +44 -12
- openlit/instrumentation/together/async_together.py +50 -27
- openlit/instrumentation/together/together.py +50 -27
- openlit/instrumentation/together/utils.py +301 -71
- openlit/instrumentation/transformers/__init__.py +2 -1
- openlit/instrumentation/transformers/transformers.py +13 -3
- openlit/instrumentation/transformers/utils.py +139 -36
- openlit/instrumentation/vertexai/__init__.py +81 -16
- openlit/instrumentation/vertexai/async_vertexai.py +33 -15
- openlit/instrumentation/vertexai/utils.py +123 -27
- openlit/instrumentation/vertexai/vertexai.py +33 -15
- openlit/instrumentation/vllm/__init__.py +12 -5
- openlit/instrumentation/vllm/utils.py +121 -31
- openlit/instrumentation/vllm/vllm.py +16 -10
- openlit/otel/events.py +35 -10
- openlit/otel/metrics.py +32 -24
- openlit/otel/tracing.py +24 -9
- openlit/semcov/__init__.py +101 -7
- {openlit-1.34.29.dist-info → openlit-1.34.31.dist-info}/METADATA +2 -1
- openlit-1.34.31.dist-info/RECORD +166 -0
- openlit/instrumentation/langchain/async_langchain.py +0 -102
- openlit/instrumentation/langchain/langchain.py +0 -102
- openlit/instrumentation/langchain/utils.py +0 -252
- openlit-1.34.29.dist-info/RECORD +0 -166
- {openlit-1.34.29.dist-info → openlit-1.34.31.dist-info}/LICENSE +0 -0
- {openlit-1.34.29.dist-info → openlit-1.34.31.dist-info}/WHEEL +0 -0
@@ -35,6 +35,7 @@ DB_OPERATION_MAP = {
|
|
35
35
|
"qdrant.create_payload_index": SemanticConvention.DB_OPERATION_CREATE_INDEX,
|
36
36
|
}
|
37
37
|
|
38
|
+
|
38
39
|
def object_count(obj):
|
39
40
|
"""
|
40
41
|
Counts Length of object if it exists, Else returns 0.
|
@@ -44,6 +45,7 @@ def object_count(obj):
|
|
44
45
|
except (TypeError, AttributeError):
|
45
46
|
return 0
|
46
47
|
|
48
|
+
|
47
49
|
def set_server_address_and_port(instance):
|
48
50
|
"""
|
49
51
|
Extracts server address and port from Qdrant client instance.
|
@@ -79,75 +81,117 @@ def set_server_address_and_port(instance):
|
|
79
81
|
|
80
82
|
return server_address, server_port
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
|
85
|
+
def common_qdrant_logic(
|
86
|
+
scope,
|
87
|
+
environment,
|
88
|
+
application_name,
|
89
|
+
metrics,
|
90
|
+
capture_message_content,
|
91
|
+
disable_metrics,
|
92
|
+
version,
|
93
|
+
instance=None,
|
94
|
+
endpoint=None,
|
95
|
+
):
|
85
96
|
"""
|
86
97
|
Process Qdrant request and generate telemetry.
|
87
98
|
"""
|
88
99
|
scope._end_time = time.time()
|
89
100
|
|
90
101
|
# Set common database span attributes using helper
|
91
|
-
common_db_span_attributes(
|
92
|
-
scope
|
93
|
-
|
102
|
+
common_db_span_attributes(
|
103
|
+
scope,
|
104
|
+
SemanticConvention.DB_SYSTEM_QDRANT,
|
105
|
+
scope._server_address,
|
106
|
+
scope._server_port,
|
107
|
+
environment,
|
108
|
+
application_name,
|
109
|
+
version,
|
110
|
+
)
|
94
111
|
|
95
112
|
# Set DB operation specific attributes
|
96
113
|
scope._span.set_attribute(SemanticConvention.DB_OPERATION_NAME, scope._db_operation)
|
97
|
-
scope._span.set_attribute(
|
98
|
-
|
114
|
+
scope._span.set_attribute(
|
115
|
+
SemanticConvention.DB_CLIENT_OPERATION_DURATION,
|
116
|
+
scope._end_time - scope._start_time,
|
117
|
+
)
|
99
118
|
|
100
119
|
# Handle collection management operations
|
101
|
-
if scope._db_operation in [
|
102
|
-
|
103
|
-
|
120
|
+
if scope._db_operation in [
|
121
|
+
SemanticConvention.DB_OPERATION_CREATE_COLLECTION,
|
122
|
+
SemanticConvention.DB_OPERATION_DELETE_COLLECTION,
|
123
|
+
SemanticConvention.DB_OPERATION_UPDATE_COLLECTION,
|
124
|
+
]:
|
104
125
|
collection_name = scope._kwargs.get("collection_name", "unknown")
|
105
126
|
|
106
|
-
scope._span.set_attribute(
|
107
|
-
|
108
|
-
|
109
|
-
scope._span.set_attribute(
|
110
|
-
f"
|
127
|
+
scope._span.set_attribute(
|
128
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
129
|
+
)
|
130
|
+
scope._span.set_attribute(
|
131
|
+
SemanticConvention.DB_QUERY_TEXT, f"Collection: {collection_name}"
|
132
|
+
)
|
133
|
+
scope._span.set_attribute(
|
134
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
135
|
+
f"{scope._db_operation} {collection_name}",
|
136
|
+
)
|
111
137
|
|
112
138
|
# Handle data insertion operations
|
113
|
-
elif scope._db_operation in [
|
114
|
-
|
139
|
+
elif scope._db_operation in [
|
140
|
+
SemanticConvention.DB_OPERATION_INSERT,
|
141
|
+
SemanticConvention.DB_OPERATION_UPSERT,
|
142
|
+
]:
|
115
143
|
collection_name = scope._kwargs.get("collection_name", "unknown")
|
116
144
|
|
117
145
|
if endpoint == "qdrant.set_payload":
|
118
146
|
points = scope._kwargs.get("points", [])
|
119
147
|
payload = scope._kwargs.get("payload", {})
|
120
148
|
|
121
|
-
scope._span.set_attribute(
|
149
|
+
scope._span.set_attribute(
|
150
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
151
|
+
)
|
122
152
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(points))
|
123
|
-
scope._span.set_attribute(
|
124
|
-
|
153
|
+
scope._span.set_attribute(
|
154
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(points)
|
155
|
+
)
|
156
|
+
scope._span.set_attribute(
|
157
|
+
SemanticConvention.DB_PAYLOAD_COUNT, object_count(payload)
|
158
|
+
)
|
125
159
|
|
126
160
|
# Set operation status if response available
|
127
161
|
if scope._response and hasattr(scope._response, "status"):
|
128
|
-
scope._span.set_attribute(
|
129
|
-
scope._response.status
|
162
|
+
scope._span.set_attribute(
|
163
|
+
SemanticConvention.DB_OPERATION_STATUS, scope._response.status
|
164
|
+
)
|
130
165
|
|
131
|
-
scope._span.set_attribute(
|
166
|
+
scope._span.set_attribute(
|
167
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
132
168
|
f"{scope._db_operation} {collection_name} "
|
133
169
|
f"points={object_count(points)} "
|
134
|
-
f"payload={object_count(payload)}"
|
170
|
+
f"payload={object_count(payload)}",
|
171
|
+
)
|
135
172
|
|
136
173
|
elif endpoint in ["qdrant.upsert", "qdrant.upload_points"]:
|
137
174
|
points = scope._kwargs.get("points", [])
|
138
175
|
|
139
|
-
scope._span.set_attribute(
|
176
|
+
scope._span.set_attribute(
|
177
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
178
|
+
)
|
140
179
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(points))
|
141
|
-
scope._span.set_attribute(
|
180
|
+
scope._span.set_attribute(
|
181
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(points)
|
182
|
+
)
|
142
183
|
|
143
184
|
# Set operation status if response available
|
144
185
|
if scope._response and hasattr(scope._response, "status"):
|
145
|
-
scope._span.set_attribute(
|
146
|
-
scope._response.status
|
186
|
+
scope._span.set_attribute(
|
187
|
+
SemanticConvention.DB_OPERATION_STATUS, scope._response.status
|
188
|
+
)
|
147
189
|
|
148
|
-
scope._span.set_attribute(
|
190
|
+
scope._span.set_attribute(
|
191
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
149
192
|
f"{scope._db_operation} {collection_name} "
|
150
|
-
f"points={object_count(points)}"
|
193
|
+
f"points={object_count(points)}",
|
194
|
+
)
|
151
195
|
|
152
196
|
# Handle data update operations
|
153
197
|
elif scope._db_operation == SemanticConvention.DB_OPERATION_UPDATE:
|
@@ -157,36 +201,52 @@ def common_qdrant_logic(scope, environment, application_name,
|
|
157
201
|
points = scope._kwargs.get("points", [])
|
158
202
|
payload = scope._kwargs.get("payload", {})
|
159
203
|
|
160
|
-
scope._span.set_attribute(
|
204
|
+
scope._span.set_attribute(
|
205
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
206
|
+
)
|
161
207
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(points))
|
162
|
-
scope._span.set_attribute(
|
163
|
-
|
208
|
+
scope._span.set_attribute(
|
209
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(points)
|
210
|
+
)
|
211
|
+
scope._span.set_attribute(
|
212
|
+
SemanticConvention.DB_PAYLOAD_COUNT, object_count(payload)
|
213
|
+
)
|
164
214
|
|
165
215
|
# Set operation status if response available
|
166
216
|
if scope._response and hasattr(scope._response, "status"):
|
167
|
-
scope._span.set_attribute(
|
168
|
-
scope._response.status
|
217
|
+
scope._span.set_attribute(
|
218
|
+
SemanticConvention.DB_OPERATION_STATUS, scope._response.status
|
219
|
+
)
|
169
220
|
|
170
|
-
scope._span.set_attribute(
|
221
|
+
scope._span.set_attribute(
|
222
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
171
223
|
f"{scope._db_operation} {collection_name} "
|
172
224
|
f"points={object_count(points)} "
|
173
|
-
f"payload={object_count(payload)}"
|
225
|
+
f"payload={object_count(payload)}",
|
226
|
+
)
|
174
227
|
|
175
228
|
elif endpoint == "qdrant.update_vectors":
|
176
229
|
points = scope._kwargs.get("points", [])
|
177
230
|
|
178
|
-
scope._span.set_attribute(
|
231
|
+
scope._span.set_attribute(
|
232
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
233
|
+
)
|
179
234
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(points))
|
180
|
-
scope._span.set_attribute(
|
235
|
+
scope._span.set_attribute(
|
236
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(points)
|
237
|
+
)
|
181
238
|
|
182
239
|
# Set operation status if response available
|
183
240
|
if scope._response and hasattr(scope._response, "status"):
|
184
|
-
scope._span.set_attribute(
|
185
|
-
scope._response.status
|
241
|
+
scope._span.set_attribute(
|
242
|
+
SemanticConvention.DB_OPERATION_STATUS, scope._response.status
|
243
|
+
)
|
186
244
|
|
187
|
-
scope._span.set_attribute(
|
245
|
+
scope._span.set_attribute(
|
246
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
188
247
|
f"{scope._db_operation} {collection_name} "
|
189
|
-
f"points={object_count(points)}"
|
248
|
+
f"points={object_count(points)}",
|
249
|
+
)
|
190
250
|
|
191
251
|
# Handle data deletion operations
|
192
252
|
elif scope._db_operation == SemanticConvention.DB_OPERATION_DELETE:
|
@@ -195,34 +255,50 @@ def common_qdrant_logic(scope, environment, application_name,
|
|
195
255
|
if endpoint in ["qdrant.delete_payload", "qdrant.delete_vectors"]:
|
196
256
|
points = scope._kwargs.get("points", [])
|
197
257
|
|
198
|
-
scope._span.set_attribute(
|
258
|
+
scope._span.set_attribute(
|
259
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
260
|
+
)
|
199
261
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(points))
|
200
|
-
scope._span.set_attribute(
|
262
|
+
scope._span.set_attribute(
|
263
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(points)
|
264
|
+
)
|
201
265
|
|
202
266
|
# Set operation status if response available
|
203
267
|
if scope._response and hasattr(scope._response, "status"):
|
204
|
-
scope._span.set_attribute(
|
205
|
-
scope._response.status
|
268
|
+
scope._span.set_attribute(
|
269
|
+
SemanticConvention.DB_OPERATION_STATUS, scope._response.status
|
270
|
+
)
|
206
271
|
|
207
|
-
scope._span.set_attribute(
|
272
|
+
scope._span.set_attribute(
|
273
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
208
274
|
f"{scope._db_operation} {collection_name} "
|
209
|
-
f"points={object_count(points)}"
|
275
|
+
f"points={object_count(points)}",
|
276
|
+
)
|
210
277
|
|
211
278
|
elif endpoint in ["qdrant.clear_payload", "qdrant.delete"]:
|
212
279
|
points_selector = scope._kwargs.get("points_selector", [])
|
213
280
|
|
214
|
-
scope._span.set_attribute(
|
215
|
-
|
216
|
-
|
281
|
+
scope._span.set_attribute(
|
282
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
283
|
+
)
|
284
|
+
scope._span.set_attribute(
|
285
|
+
SemanticConvention.DB_QUERY_TEXT, str(points_selector)
|
286
|
+
)
|
287
|
+
scope._span.set_attribute(
|
288
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(points_selector)
|
289
|
+
)
|
217
290
|
|
218
291
|
# Set operation status if response available
|
219
292
|
if scope._response and hasattr(scope._response, "status"):
|
220
|
-
scope._span.set_attribute(
|
221
|
-
scope._response.status
|
293
|
+
scope._span.set_attribute(
|
294
|
+
SemanticConvention.DB_OPERATION_STATUS, scope._response.status
|
295
|
+
)
|
222
296
|
|
223
|
-
scope._span.set_attribute(
|
297
|
+
scope._span.set_attribute(
|
298
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
224
299
|
f"{scope._db_operation} {collection_name} "
|
225
|
-
f"selector={object_count(points_selector)}"
|
300
|
+
f"selector={object_count(points_selector)}",
|
301
|
+
)
|
226
302
|
|
227
303
|
# Handle query operations
|
228
304
|
elif scope._db_operation == SemanticConvention.DB_OPERATION_GET:
|
@@ -231,82 +307,133 @@ def common_qdrant_logic(scope, environment, application_name,
|
|
231
307
|
if endpoint == "qdrant.retrieve":
|
232
308
|
ids = scope._kwargs.get("ids", [])
|
233
309
|
|
234
|
-
scope._span.set_attribute(
|
310
|
+
scope._span.set_attribute(
|
311
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
312
|
+
)
|
235
313
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(ids))
|
236
|
-
scope._span.set_attribute(
|
314
|
+
scope._span.set_attribute(
|
315
|
+
SemanticConvention.DB_VECTOR_COUNT, object_count(ids)
|
316
|
+
)
|
237
317
|
|
238
|
-
scope._span.set_attribute(
|
239
|
-
|
318
|
+
scope._span.set_attribute(
|
319
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
320
|
+
f"{scope._db_operation} {collection_name} ids={ids}",
|
321
|
+
)
|
240
322
|
|
241
323
|
elif endpoint == "qdrant.scroll":
|
242
324
|
scroll_filter = scope._kwargs.get("scroll_filter", {})
|
243
325
|
|
244
|
-
scope._span.set_attribute(
|
245
|
-
|
326
|
+
scope._span.set_attribute(
|
327
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
328
|
+
)
|
329
|
+
scope._span.set_attribute(
|
330
|
+
SemanticConvention.DB_QUERY_TEXT, str(scroll_filter)
|
331
|
+
)
|
246
332
|
scope._span.set_attribute(SemanticConvention.DB_FILTER, str(scroll_filter))
|
247
333
|
|
248
|
-
scope._span.set_attribute(
|
249
|
-
|
250
|
-
f"filter={scroll_filter}"
|
334
|
+
scope._span.set_attribute(
|
335
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
336
|
+
f"{scope._db_operation} {collection_name} filter={scroll_filter}",
|
337
|
+
)
|
251
338
|
|
252
339
|
elif endpoint in ["qdrant.search", "qdrant.search_groups"]:
|
253
340
|
query_vector = scope._kwargs.get("query_vector", [])
|
254
341
|
limit = scope._kwargs.get("limit", 10)
|
255
342
|
|
256
|
-
scope._span.set_attribute(
|
257
|
-
|
343
|
+
scope._span.set_attribute(
|
344
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
345
|
+
)
|
346
|
+
scope._span.set_attribute(
|
347
|
+
SemanticConvention.DB_QUERY_TEXT, str(query_vector)
|
348
|
+
)
|
258
349
|
scope._span.set_attribute(SemanticConvention.DB_VECTOR_QUERY_TOP_K, limit)
|
259
350
|
|
260
|
-
scope._span.set_attribute(
|
261
|
-
|
262
|
-
f"limit={limit}"
|
351
|
+
scope._span.set_attribute(
|
352
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
353
|
+
f"{scope._db_operation} {collection_name} limit={limit}",
|
354
|
+
)
|
263
355
|
|
264
356
|
elif endpoint == "qdrant.recommend":
|
265
357
|
positive = scope._kwargs.get("positive", [])
|
266
358
|
negative = scope._kwargs.get("negative", [])
|
267
359
|
|
268
|
-
scope._span.set_attribute(
|
360
|
+
scope._span.set_attribute(
|
361
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
362
|
+
)
|
269
363
|
query_content = f"positive:{positive} negative:{negative}"
|
270
364
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, query_content)
|
271
365
|
|
272
|
-
scope._span.set_attribute(
|
366
|
+
scope._span.set_attribute(
|
367
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
273
368
|
f"{scope._db_operation} {collection_name} "
|
274
369
|
f"positive={object_count(positive)} "
|
275
|
-
f"negative={object_count(negative)}"
|
370
|
+
f"negative={object_count(negative)}",
|
371
|
+
)
|
276
372
|
|
277
373
|
elif endpoint == "qdrant.query_points":
|
278
374
|
query = scope._kwargs.get("query", {})
|
279
375
|
|
280
|
-
scope._span.set_attribute(
|
376
|
+
scope._span.set_attribute(
|
377
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
378
|
+
)
|
281
379
|
scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query))
|
282
380
|
|
283
|
-
scope._span.set_attribute(
|
284
|
-
|
381
|
+
scope._span.set_attribute(
|
382
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
383
|
+
f"{scope._db_operation} {collection_name} query={query}",
|
384
|
+
)
|
285
385
|
|
286
386
|
# Handle index operations
|
287
387
|
elif scope._db_operation == SemanticConvention.DB_OPERATION_CREATE_INDEX:
|
288
388
|
collection_name = scope._kwargs.get("collection_name", "unknown")
|
289
389
|
field_name = scope._kwargs.get("field_name", "unknown")
|
290
390
|
|
291
|
-
scope._span.set_attribute(
|
292
|
-
|
391
|
+
scope._span.set_attribute(
|
392
|
+
SemanticConvention.DB_COLLECTION_NAME, collection_name
|
393
|
+
)
|
394
|
+
scope._span.set_attribute(
|
395
|
+
SemanticConvention.DB_QUERY_TEXT, f"Field: {field_name}"
|
396
|
+
)
|
293
397
|
|
294
|
-
scope._span.set_attribute(
|
295
|
-
|
398
|
+
scope._span.set_attribute(
|
399
|
+
SemanticConvention.DB_QUERY_SUMMARY,
|
400
|
+
f"{scope._db_operation} {collection_name} field={field_name}",
|
401
|
+
)
|
296
402
|
|
297
403
|
scope._span.set_status(Status(StatusCode.OK))
|
298
404
|
|
299
405
|
# Record metrics using helper
|
300
406
|
if not disable_metrics:
|
301
|
-
record_db_metrics(
|
302
|
-
|
303
|
-
|
304
|
-
scope.
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
407
|
+
record_db_metrics(
|
408
|
+
metrics,
|
409
|
+
SemanticConvention.DB_SYSTEM_QDRANT,
|
410
|
+
scope._server_address,
|
411
|
+
scope._server_port,
|
412
|
+
environment,
|
413
|
+
application_name,
|
414
|
+
scope._start_time,
|
415
|
+
scope._end_time,
|
416
|
+
)
|
417
|
+
|
418
|
+
|
419
|
+
def process_qdrant_response(
|
420
|
+
response,
|
421
|
+
db_operation,
|
422
|
+
server_address,
|
423
|
+
server_port,
|
424
|
+
environment,
|
425
|
+
application_name,
|
426
|
+
metrics,
|
427
|
+
start_time,
|
428
|
+
span,
|
429
|
+
capture_message_content,
|
430
|
+
disable_metrics,
|
431
|
+
version,
|
432
|
+
instance=None,
|
433
|
+
args=None,
|
434
|
+
endpoint=None,
|
435
|
+
**kwargs,
|
436
|
+
):
|
310
437
|
"""
|
311
438
|
Process Qdrant response and generate telemetry.
|
312
439
|
"""
|
@@ -321,8 +448,16 @@ def process_qdrant_response(response, db_operation, server_address, server_port,
|
|
321
448
|
scope._kwargs = kwargs
|
322
449
|
|
323
450
|
# Process the response
|
324
|
-
common_qdrant_logic(
|
325
|
-
|
326
|
-
|
451
|
+
common_qdrant_logic(
|
452
|
+
scope,
|
453
|
+
environment,
|
454
|
+
application_name,
|
455
|
+
metrics,
|
456
|
+
capture_message_content,
|
457
|
+
disable_metrics,
|
458
|
+
version,
|
459
|
+
instance=instance,
|
460
|
+
endpoint=endpoint,
|
461
|
+
)
|
327
462
|
|
328
463
|
return response
|
@@ -5,15 +5,12 @@ import importlib.metadata
|
|
5
5
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
6
6
|
from wrapt import wrap_function_wrapper
|
7
7
|
|
8
|
-
from openlit.instrumentation.reka.reka import
|
9
|
-
|
10
|
-
)
|
11
|
-
from openlit.instrumentation.reka.async_reka import (
|
12
|
-
async_chat
|
13
|
-
)
|
8
|
+
from openlit.instrumentation.reka.reka import chat
|
9
|
+
from openlit.instrumentation.reka.async_reka import async_chat
|
14
10
|
|
15
11
|
_instruments = ("reka-api >= 3.2.0",)
|
16
12
|
|
13
|
+
|
17
14
|
class RekaInstrumentor(BaseInstrumentor):
|
18
15
|
"""
|
19
16
|
An instrumentor for Reka client library.
|
@@ -36,16 +33,32 @@ class RekaInstrumentor(BaseInstrumentor):
|
|
36
33
|
wrap_function_wrapper(
|
37
34
|
"reka.chat.client",
|
38
35
|
"ChatClient.create",
|
39
|
-
chat(
|
40
|
-
|
36
|
+
chat(
|
37
|
+
version,
|
38
|
+
environment,
|
39
|
+
application_name,
|
40
|
+
tracer,
|
41
|
+
pricing_info,
|
42
|
+
capture_message_content,
|
43
|
+
metrics,
|
44
|
+
disable_metrics,
|
45
|
+
),
|
41
46
|
)
|
42
47
|
|
43
48
|
# Chat completions
|
44
49
|
wrap_function_wrapper(
|
45
50
|
"reka.chat.client",
|
46
51
|
"AsyncChatClient.create",
|
47
|
-
async_chat(
|
48
|
-
|
52
|
+
async_chat(
|
53
|
+
version,
|
54
|
+
environment,
|
55
|
+
application_name,
|
56
|
+
tracer,
|
57
|
+
pricing_info,
|
58
|
+
capture_message_content,
|
59
|
+
metrics,
|
60
|
+
disable_metrics,
|
61
|
+
),
|
49
62
|
)
|
50
63
|
|
51
64
|
def _uninstrument(self, **kwargs):
|
@@ -4,17 +4,21 @@ Module for monitoring Reka API calls.
|
|
4
4
|
|
5
5
|
import time
|
6
6
|
from opentelemetry.trace import SpanKind
|
7
|
-
from openlit.__helpers import
|
8
|
-
|
9
|
-
set_server_address_and_port
|
10
|
-
)
|
11
|
-
from openlit.instrumentation.reka.utils import (
|
12
|
-
process_chat_response
|
13
|
-
)
|
7
|
+
from openlit.__helpers import handle_exception, set_server_address_and_port
|
8
|
+
from openlit.instrumentation.reka.utils import process_chat_response
|
14
9
|
from openlit.semcov import SemanticConvention
|
15
10
|
|
16
|
-
|
17
|
-
|
11
|
+
|
12
|
+
def async_chat(
|
13
|
+
version,
|
14
|
+
environment,
|
15
|
+
application_name,
|
16
|
+
tracer,
|
17
|
+
pricing_info,
|
18
|
+
capture_message_content,
|
19
|
+
metrics,
|
20
|
+
disable_metrics,
|
21
|
+
):
|
18
22
|
"""
|
19
23
|
Generates a telemetry wrapper for GenAI function call
|
20
24
|
"""
|
@@ -24,7 +28,9 @@ def async_chat(version, environment, application_name,
|
|
24
28
|
Wraps the GenAI function call.
|
25
29
|
"""
|
26
30
|
|
27
|
-
server_address, server_port = set_server_address_and_port(
|
31
|
+
server_address, server_port = set_server_address_and_port(
|
32
|
+
instance, "api.reka.ai", 443
|
33
|
+
)
|
28
34
|
request_model = kwargs.get("model", "reka-core-20240501")
|
29
35
|
|
30
36
|
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
@@ -48,7 +54,7 @@ def async_chat(version, environment, application_name,
|
|
48
54
|
capture_message_content=capture_message_content,
|
49
55
|
disable_metrics=disable_metrics,
|
50
56
|
version=version,
|
51
|
-
**kwargs
|
57
|
+
**kwargs,
|
52
58
|
)
|
53
59
|
|
54
60
|
except Exception as e:
|
@@ -4,17 +4,21 @@ Module for monitoring Reka API calls.
|
|
4
4
|
|
5
5
|
import time
|
6
6
|
from opentelemetry.trace import SpanKind
|
7
|
-
from openlit.__helpers import
|
8
|
-
|
9
|
-
set_server_address_and_port
|
10
|
-
)
|
11
|
-
from openlit.instrumentation.reka.utils import (
|
12
|
-
process_chat_response
|
13
|
-
)
|
7
|
+
from openlit.__helpers import handle_exception, set_server_address_and_port
|
8
|
+
from openlit.instrumentation.reka.utils import process_chat_response
|
14
9
|
from openlit.semcov import SemanticConvention
|
15
10
|
|
16
|
-
|
17
|
-
|
11
|
+
|
12
|
+
def chat(
|
13
|
+
version,
|
14
|
+
environment,
|
15
|
+
application_name,
|
16
|
+
tracer,
|
17
|
+
pricing_info,
|
18
|
+
capture_message_content,
|
19
|
+
metrics,
|
20
|
+
disable_metrics,
|
21
|
+
):
|
18
22
|
"""
|
19
23
|
Generates a telemetry wrapper for GenAI function call
|
20
24
|
"""
|
@@ -24,7 +28,9 @@ def chat(version, environment, application_name,
|
|
24
28
|
Wraps the GenAI function call.
|
25
29
|
"""
|
26
30
|
|
27
|
-
server_address, server_port = set_server_address_and_port(
|
31
|
+
server_address, server_port = set_server_address_and_port(
|
32
|
+
instance, "api.reka.ai", 443
|
33
|
+
)
|
28
34
|
request_model = kwargs.get("model", "reka-core-20240501")
|
29
35
|
|
30
36
|
span_name = f"{SemanticConvention.GEN_AI_OPERATION_TYPE_CHAT} {request_model}"
|
@@ -48,7 +54,7 @@ def chat(version, environment, application_name,
|
|
48
54
|
capture_message_content=capture_message_content,
|
49
55
|
disable_metrics=disable_metrics,
|
50
56
|
version=version,
|
51
|
-
**kwargs
|
57
|
+
**kwargs,
|
52
58
|
)
|
53
59
|
|
54
60
|
except Exception as e:
|