openlit 1.34.30__py3-none-any.whl → 1.34.32__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.
Files changed (168) hide show
  1. openlit/__helpers.py +235 -86
  2. openlit/__init__.py +19 -14
  3. openlit/_instrumentors.py +2 -1
  4. openlit/evals/all.py +50 -21
  5. openlit/evals/bias_detection.py +47 -20
  6. openlit/evals/hallucination.py +53 -22
  7. openlit/evals/toxicity.py +50 -21
  8. openlit/evals/utils.py +54 -30
  9. openlit/guard/all.py +61 -19
  10. openlit/guard/prompt_injection.py +34 -14
  11. openlit/guard/restrict_topic.py +46 -15
  12. openlit/guard/sensitive_topic.py +34 -14
  13. openlit/guard/utils.py +58 -22
  14. openlit/instrumentation/ag2/__init__.py +113 -6
  15. openlit/instrumentation/ag2/ag2.py +459 -17
  16. openlit/instrumentation/ag2/async_ag2.py +459 -17
  17. openlit/instrumentation/ag2/utils.py +475 -31
  18. openlit/instrumentation/ai21/__init__.py +43 -14
  19. openlit/instrumentation/ai21/ai21.py +47 -21
  20. openlit/instrumentation/ai21/async_ai21.py +47 -21
  21. openlit/instrumentation/ai21/utils.py +299 -78
  22. openlit/instrumentation/anthropic/__init__.py +21 -4
  23. openlit/instrumentation/anthropic/anthropic.py +28 -17
  24. openlit/instrumentation/anthropic/async_anthropic.py +28 -17
  25. openlit/instrumentation/anthropic/utils.py +145 -35
  26. openlit/instrumentation/assemblyai/__init__.py +11 -2
  27. openlit/instrumentation/assemblyai/assemblyai.py +15 -4
  28. openlit/instrumentation/assemblyai/utils.py +120 -25
  29. openlit/instrumentation/astra/__init__.py +43 -10
  30. openlit/instrumentation/astra/astra.py +28 -5
  31. openlit/instrumentation/astra/async_astra.py +28 -5
  32. openlit/instrumentation/astra/utils.py +151 -55
  33. openlit/instrumentation/azure_ai_inference/__init__.py +43 -10
  34. openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py +53 -21
  35. openlit/instrumentation/azure_ai_inference/azure_ai_inference.py +53 -21
  36. openlit/instrumentation/azure_ai_inference/utils.py +307 -83
  37. openlit/instrumentation/bedrock/__init__.py +21 -4
  38. openlit/instrumentation/bedrock/bedrock.py +63 -25
  39. openlit/instrumentation/bedrock/utils.py +139 -30
  40. openlit/instrumentation/chroma/__init__.py +89 -16
  41. openlit/instrumentation/chroma/chroma.py +28 -6
  42. openlit/instrumentation/chroma/utils.py +167 -51
  43. openlit/instrumentation/cohere/__init__.py +63 -18
  44. openlit/instrumentation/cohere/async_cohere.py +63 -24
  45. openlit/instrumentation/cohere/cohere.py +63 -24
  46. openlit/instrumentation/cohere/utils.py +286 -73
  47. openlit/instrumentation/controlflow/__init__.py +35 -9
  48. openlit/instrumentation/controlflow/controlflow.py +66 -33
  49. openlit/instrumentation/crawl4ai/__init__.py +25 -10
  50. openlit/instrumentation/crawl4ai/async_crawl4ai.py +78 -31
  51. openlit/instrumentation/crawl4ai/crawl4ai.py +78 -31
  52. openlit/instrumentation/crewai/__init__.py +40 -15
  53. openlit/instrumentation/crewai/async_crewai.py +32 -7
  54. openlit/instrumentation/crewai/crewai.py +32 -7
  55. openlit/instrumentation/crewai/utils.py +159 -56
  56. openlit/instrumentation/dynamiq/__init__.py +46 -12
  57. openlit/instrumentation/dynamiq/dynamiq.py +74 -33
  58. openlit/instrumentation/elevenlabs/__init__.py +23 -4
  59. openlit/instrumentation/elevenlabs/async_elevenlabs.py +16 -4
  60. openlit/instrumentation/elevenlabs/elevenlabs.py +16 -4
  61. openlit/instrumentation/elevenlabs/utils.py +128 -25
  62. openlit/instrumentation/embedchain/__init__.py +11 -2
  63. openlit/instrumentation/embedchain/embedchain.py +68 -35
  64. openlit/instrumentation/firecrawl/__init__.py +24 -7
  65. openlit/instrumentation/firecrawl/firecrawl.py +46 -20
  66. openlit/instrumentation/google_ai_studio/__init__.py +45 -10
  67. openlit/instrumentation/google_ai_studio/async_google_ai_studio.py +67 -44
  68. openlit/instrumentation/google_ai_studio/google_ai_studio.py +67 -44
  69. openlit/instrumentation/google_ai_studio/utils.py +180 -67
  70. openlit/instrumentation/gpt4all/__init__.py +22 -7
  71. openlit/instrumentation/gpt4all/gpt4all.py +67 -29
  72. openlit/instrumentation/gpt4all/utils.py +285 -61
  73. openlit/instrumentation/gpu/__init__.py +128 -47
  74. openlit/instrumentation/groq/__init__.py +21 -4
  75. openlit/instrumentation/groq/async_groq.py +33 -21
  76. openlit/instrumentation/groq/groq.py +33 -21
  77. openlit/instrumentation/groq/utils.py +192 -55
  78. openlit/instrumentation/haystack/__init__.py +70 -24
  79. openlit/instrumentation/haystack/async_haystack.py +28 -6
  80. openlit/instrumentation/haystack/haystack.py +28 -6
  81. openlit/instrumentation/haystack/utils.py +196 -74
  82. openlit/instrumentation/julep/__init__.py +69 -19
  83. openlit/instrumentation/julep/async_julep.py +53 -27
  84. openlit/instrumentation/julep/julep.py +53 -28
  85. openlit/instrumentation/langchain/__init__.py +74 -63
  86. openlit/instrumentation/langchain/callback_handler.py +1100 -0
  87. openlit/instrumentation/langchain_community/__init__.py +13 -2
  88. openlit/instrumentation/langchain_community/async_langchain_community.py +23 -5
  89. openlit/instrumentation/langchain_community/langchain_community.py +23 -5
  90. openlit/instrumentation/langchain_community/utils.py +35 -9
  91. openlit/instrumentation/letta/__init__.py +68 -15
  92. openlit/instrumentation/letta/letta.py +99 -54
  93. openlit/instrumentation/litellm/__init__.py +43 -14
  94. openlit/instrumentation/litellm/async_litellm.py +51 -26
  95. openlit/instrumentation/litellm/litellm.py +51 -26
  96. openlit/instrumentation/litellm/utils.py +304 -102
  97. openlit/instrumentation/llamaindex/__init__.py +267 -90
  98. openlit/instrumentation/llamaindex/async_llamaindex.py +28 -6
  99. openlit/instrumentation/llamaindex/llamaindex.py +28 -6
  100. openlit/instrumentation/llamaindex/utils.py +204 -91
  101. openlit/instrumentation/mem0/__init__.py +11 -2
  102. openlit/instrumentation/mem0/mem0.py +50 -29
  103. openlit/instrumentation/milvus/__init__.py +10 -2
  104. openlit/instrumentation/milvus/milvus.py +31 -6
  105. openlit/instrumentation/milvus/utils.py +166 -67
  106. openlit/instrumentation/mistral/__init__.py +63 -18
  107. openlit/instrumentation/mistral/async_mistral.py +63 -24
  108. openlit/instrumentation/mistral/mistral.py +63 -24
  109. openlit/instrumentation/mistral/utils.py +277 -69
  110. openlit/instrumentation/multion/__init__.py +69 -19
  111. openlit/instrumentation/multion/async_multion.py +57 -26
  112. openlit/instrumentation/multion/multion.py +57 -26
  113. openlit/instrumentation/ollama/__init__.py +39 -18
  114. openlit/instrumentation/ollama/async_ollama.py +57 -26
  115. openlit/instrumentation/ollama/ollama.py +57 -26
  116. openlit/instrumentation/ollama/utils.py +226 -50
  117. openlit/instrumentation/openai/__init__.py +156 -32
  118. openlit/instrumentation/openai/async_openai.py +147 -67
  119. openlit/instrumentation/openai/openai.py +150 -67
  120. openlit/instrumentation/openai/utils.py +657 -185
  121. openlit/instrumentation/openai_agents/__init__.py +5 -1
  122. openlit/instrumentation/openai_agents/processor.py +110 -90
  123. openlit/instrumentation/phidata/__init__.py +13 -5
  124. openlit/instrumentation/phidata/phidata.py +67 -32
  125. openlit/instrumentation/pinecone/__init__.py +48 -9
  126. openlit/instrumentation/pinecone/async_pinecone.py +27 -5
  127. openlit/instrumentation/pinecone/pinecone.py +27 -5
  128. openlit/instrumentation/pinecone/utils.py +153 -47
  129. openlit/instrumentation/premai/__init__.py +22 -7
  130. openlit/instrumentation/premai/premai.py +51 -26
  131. openlit/instrumentation/premai/utils.py +246 -59
  132. openlit/instrumentation/pydantic_ai/__init__.py +49 -22
  133. openlit/instrumentation/pydantic_ai/pydantic_ai.py +69 -16
  134. openlit/instrumentation/pydantic_ai/utils.py +89 -24
  135. openlit/instrumentation/qdrant/__init__.py +19 -4
  136. openlit/instrumentation/qdrant/async_qdrant.py +33 -7
  137. openlit/instrumentation/qdrant/qdrant.py +33 -7
  138. openlit/instrumentation/qdrant/utils.py +228 -93
  139. openlit/instrumentation/reka/__init__.py +23 -10
  140. openlit/instrumentation/reka/async_reka.py +17 -11
  141. openlit/instrumentation/reka/reka.py +17 -11
  142. openlit/instrumentation/reka/utils.py +138 -36
  143. openlit/instrumentation/together/__init__.py +44 -12
  144. openlit/instrumentation/together/async_together.py +50 -27
  145. openlit/instrumentation/together/together.py +50 -27
  146. openlit/instrumentation/together/utils.py +301 -71
  147. openlit/instrumentation/transformers/__init__.py +2 -1
  148. openlit/instrumentation/transformers/transformers.py +13 -3
  149. openlit/instrumentation/transformers/utils.py +139 -36
  150. openlit/instrumentation/vertexai/__init__.py +81 -16
  151. openlit/instrumentation/vertexai/async_vertexai.py +33 -15
  152. openlit/instrumentation/vertexai/utils.py +123 -27
  153. openlit/instrumentation/vertexai/vertexai.py +33 -15
  154. openlit/instrumentation/vllm/__init__.py +12 -5
  155. openlit/instrumentation/vllm/utils.py +121 -31
  156. openlit/instrumentation/vllm/vllm.py +16 -10
  157. openlit/otel/events.py +35 -10
  158. openlit/otel/metrics.py +32 -24
  159. openlit/otel/tracing.py +24 -9
  160. openlit/semcov/__init__.py +82 -6
  161. {openlit-1.34.30.dist-info → openlit-1.34.32.dist-info}/METADATA +2 -1
  162. openlit-1.34.32.dist-info/RECORD +166 -0
  163. openlit/instrumentation/langchain/async_langchain.py +0 -102
  164. openlit/instrumentation/langchain/langchain.py +0 -102
  165. openlit/instrumentation/langchain/utils.py +0 -252
  166. openlit-1.34.30.dist-info/RECORD +0 -168
  167. {openlit-1.34.30.dist-info → openlit-1.34.32.dist-info}/LICENSE +0 -0
  168. {openlit-1.34.30.dist-info → openlit-1.34.32.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
- def common_qdrant_logic(scope, environment, application_name,
83
- metrics, capture_message_content, disable_metrics, version,
84
- instance=None, endpoint=None):
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(scope, SemanticConvention.DB_SYSTEM_QDRANT,
92
- scope._server_address, scope._server_port,
93
- environment, application_name, version)
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(SemanticConvention.DB_CLIENT_OPERATION_DURATION,
98
- scope._end_time - scope._start_time)
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 [SemanticConvention.DB_OPERATION_CREATE_COLLECTION,
102
- SemanticConvention.DB_OPERATION_DELETE_COLLECTION,
103
- SemanticConvention.DB_OPERATION_UPDATE_COLLECTION]:
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
107
- scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT,
108
- f"Collection: {collection_name}")
109
- scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
110
- f"{scope._db_operation} {collection_name}")
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 [SemanticConvention.DB_OPERATION_INSERT,
114
- SemanticConvention.DB_OPERATION_UPSERT]:
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_VECTOR_COUNT, object_count(points))
124
- scope._span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT, object_count(payload))
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(SemanticConvention.DB_OPERATION_STATUS,
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_VECTOR_COUNT, object_count(points))
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(SemanticConvention.DB_OPERATION_STATUS,
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_VECTOR_COUNT, object_count(points))
163
- scope._span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT, object_count(payload))
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(SemanticConvention.DB_OPERATION_STATUS,
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_VECTOR_COUNT, object_count(points))
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(SemanticConvention.DB_OPERATION_STATUS,
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_VECTOR_COUNT, object_count(points))
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(SemanticConvention.DB_OPERATION_STATUS,
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
215
- scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(points_selector))
216
- scope._span.set_attribute(SemanticConvention.DB_VECTOR_COUNT, object_count(points_selector))
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(SemanticConvention.DB_OPERATION_STATUS,
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_VECTOR_COUNT, object_count(ids))
314
+ scope._span.set_attribute(
315
+ SemanticConvention.DB_VECTOR_COUNT, object_count(ids)
316
+ )
237
317
 
238
- scope._span.set_attribute(SemanticConvention.DB_QUERY_SUMMARY,
239
- f"{scope._db_operation} {collection_name} ids={ids}")
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
245
- scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(scroll_filter))
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(SemanticConvention.DB_QUERY_SUMMARY,
249
- f"{scope._db_operation} {collection_name} "
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
257
- scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, str(query_vector))
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(SemanticConvention.DB_QUERY_SUMMARY,
261
- f"{scope._db_operation} {collection_name} "
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_QUERY_SUMMARY,
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
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(SemanticConvention.DB_QUERY_SUMMARY,
284
- f"{scope._db_operation} {collection_name} query={query}")
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(SemanticConvention.DB_COLLECTION_NAME, collection_name)
292
- scope._span.set_attribute(SemanticConvention.DB_QUERY_TEXT, f"Field: {field_name}")
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(SemanticConvention.DB_QUERY_SUMMARY,
295
- f"{scope._db_operation} {collection_name} field={field_name}")
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(metrics, SemanticConvention.DB_SYSTEM_QDRANT,
302
- scope._server_address, scope._server_port,
303
- environment, application_name,
304
- scope._start_time, scope._end_time)
305
-
306
- def process_qdrant_response(response, db_operation, server_address, server_port,
307
- environment, application_name, metrics, start_time, span,
308
- capture_message_content, disable_metrics, version,
309
- instance=None, args=None, endpoint=None, **kwargs):
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(scope, environment, application_name,
325
- metrics, capture_message_content, disable_metrics, version,
326
- instance=instance, endpoint=endpoint)
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
- chat
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(version, environment, application_name,
40
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
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(version, environment, application_name,
48
- tracer, pricing_info, capture_message_content, metrics, disable_metrics),
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
- handle_exception,
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
- def async_chat(version, environment, application_name,
17
- tracer, pricing_info, capture_message_content, metrics, disable_metrics):
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(instance, "api.reka.ai", 443)
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
- handle_exception,
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
- def chat(version, environment, application_name,
17
- tracer, pricing_info, capture_message_content, metrics, disable_metrics):
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(instance, "api.reka.ai", 443)
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: