openlit 1.34.25__py3-none-any.whl → 1.34.26__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/instrumentation/chroma/__init__.py +1 -1
- openlit/instrumentation/chroma/chroma.py +6 -8
- openlit/instrumentation/chroma/utils.py +48 -3
- openlit/instrumentation/pinecone/__init__.py +46 -142
- openlit/instrumentation/pinecone/async_pinecone.py +6 -8
- openlit/instrumentation/pinecone/pinecone.py +6 -8
- openlit/instrumentation/pinecone/utils.py +41 -1
- openlit/instrumentation/qdrant/__init__.py +52 -267
- openlit/instrumentation/qdrant/async_qdrant.py +32 -244
- openlit/instrumentation/qdrant/qdrant.py +32 -251
- openlit/instrumentation/qdrant/utils.py +328 -0
- {openlit-1.34.25.dist-info → openlit-1.34.26.dist-info}/METADATA +1 -1
- {openlit-1.34.25.dist-info → openlit-1.34.26.dist-info}/RECORD +15 -14
- {openlit-1.34.25.dist-info → openlit-1.34.26.dist-info}/LICENSE +0 -0
- {openlit-1.34.25.dist-info → openlit-1.34.26.dist-info}/WHEEL +0 -0
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
"""
|
2
|
+
OpenLIT Qdrant Instrumentation
|
3
|
+
"""
|
4
|
+
|
3
5
|
from typing import Collection
|
4
6
|
import importlib.metadata
|
5
7
|
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
@@ -10,286 +12,69 @@ from openlit.instrumentation.qdrant.async_qdrant import async_general_wrap
|
|
10
12
|
|
11
13
|
_instruments = ("qdrant-client >= 1.9.0",)
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
"endpoint": "qdrant.upload_collection",
|
36
|
-
"wrapper": general_wrap,
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"package": "qdrant_client",
|
40
|
-
"object": "QdrantClient.upsert",
|
41
|
-
"endpoint": "qdrant.upsert",
|
42
|
-
"wrapper": general_wrap,
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"package": "qdrant_client",
|
46
|
-
"object": "QdrantClient.set_payload",
|
47
|
-
"endpoint": "qdrant.set_payload",
|
48
|
-
"wrapper": general_wrap,
|
49
|
-
},
|
50
|
-
{
|
51
|
-
"package": "qdrant_client",
|
52
|
-
"object": "QdrantClient.overwrite_payload",
|
53
|
-
"endpoint": "qdrant.overwrite_payload",
|
54
|
-
"wrapper": general_wrap,
|
55
|
-
},
|
56
|
-
{
|
57
|
-
"package": "qdrant_client",
|
58
|
-
"object": "QdrantClient.clear_payload",
|
59
|
-
"endpoint": "qdrant.clear_payload",
|
60
|
-
"wrapper": general_wrap,
|
61
|
-
},
|
62
|
-
{
|
63
|
-
"package": "qdrant_client",
|
64
|
-
"object": "QdrantClient.delete_payload",
|
65
|
-
"endpoint": "qdrant.delete_payload",
|
66
|
-
"wrapper": general_wrap,
|
67
|
-
},
|
68
|
-
{
|
69
|
-
"package": "qdrant_client",
|
70
|
-
"object": "QdrantClient.upload_points",
|
71
|
-
"endpoint": "qdrant.upload_points",
|
72
|
-
"wrapper": general_wrap,
|
73
|
-
},
|
74
|
-
{
|
75
|
-
"package": "qdrant_client",
|
76
|
-
"object": "QdrantClient.update_vectors",
|
77
|
-
"endpoint": "qdrant.update_vectors",
|
78
|
-
"wrapper": general_wrap,
|
79
|
-
},
|
80
|
-
{
|
81
|
-
"package": "qdrant_client",
|
82
|
-
"object": "QdrantClient.delete_vectors",
|
83
|
-
"endpoint": "qdrant.delete_vectors",
|
84
|
-
"wrapper": general_wrap,
|
85
|
-
},
|
86
|
-
{
|
87
|
-
"package": "qdrant_client",
|
88
|
-
"object": "QdrantClient.delete",
|
89
|
-
"endpoint": "qdrant.delete",
|
90
|
-
"wrapper": general_wrap,
|
91
|
-
},
|
92
|
-
{
|
93
|
-
"package": "qdrant_client",
|
94
|
-
"object": "QdrantClient.retrieve",
|
95
|
-
"endpoint": "qdrant.retrieve",
|
96
|
-
"wrapper": general_wrap,
|
97
|
-
},
|
98
|
-
{
|
99
|
-
"package": "qdrant_client",
|
100
|
-
"object": "QdrantClient.scroll",
|
101
|
-
"endpoint": "qdrant.scroll",
|
102
|
-
"wrapper": general_wrap,
|
103
|
-
},
|
104
|
-
{
|
105
|
-
"package": "qdrant_client",
|
106
|
-
"object": "QdrantClient.search",
|
107
|
-
"endpoint": "qdrant.search",
|
108
|
-
"wrapper": general_wrap,
|
109
|
-
},
|
110
|
-
{
|
111
|
-
"package": "qdrant_client",
|
112
|
-
"object": "QdrantClient.search_groups",
|
113
|
-
"endpoint": "qdrant.search_groups",
|
114
|
-
"wrapper": general_wrap,
|
115
|
-
},
|
116
|
-
{
|
117
|
-
|
118
|
-
"package": "qdrant_client",
|
119
|
-
"object": "QdrantClient.recommend",
|
120
|
-
"endpoint": "qdrant.recommend",
|
121
|
-
"wrapper": general_wrap,
|
122
|
-
},
|
123
|
-
{
|
124
|
-
|
125
|
-
"package": "qdrant_client",
|
126
|
-
"object": "QdrantClient.create_payload_index",
|
127
|
-
"endpoint": "qdrant.create_payload_index",
|
128
|
-
"wrapper": general_wrap,
|
129
|
-
},
|
130
|
-
{
|
131
|
-
|
132
|
-
"package": "qdrant_client",
|
133
|
-
"object": "QdrantClient.query_points",
|
134
|
-
"endpoint": "qdrant.query_points",
|
135
|
-
"wrapper": general_wrap,
|
136
|
-
},
|
137
|
-
|
138
|
-
# Async Client
|
139
|
-
{
|
140
|
-
"package": "qdrant_client",
|
141
|
-
"object": "AsyncQdrantClient.create_collection",
|
142
|
-
"endpoint": "qdrant.create_collection",
|
143
|
-
"wrapper": async_general_wrap,
|
144
|
-
},
|
145
|
-
{
|
146
|
-
"package": "qdrant_client",
|
147
|
-
"object": "AsyncQdrantClient.delete_collection",
|
148
|
-
"endpoint": "qdrant.delete_collection",
|
149
|
-
"wrapper": async_general_wrap,
|
150
|
-
},
|
151
|
-
{
|
152
|
-
"package": "qdrant_client",
|
153
|
-
"object": "AsyncQdrantClient.update_collection",
|
154
|
-
"endpoint": "qdrant.update_collection",
|
155
|
-
"wrapper": async_general_wrap,
|
156
|
-
},
|
157
|
-
{
|
158
|
-
"package": "qdrant_client",
|
159
|
-
"object": "AsyncQdrantClient.upload_collection",
|
160
|
-
"endpoint": "qdrant.upload_collection",
|
161
|
-
"wrapper": async_general_wrap,
|
162
|
-
},
|
163
|
-
{
|
164
|
-
"package": "qdrant_client",
|
165
|
-
"object": "AsyncQdrantClient.upsert",
|
166
|
-
"endpoint": "qdrant.upsert",
|
167
|
-
"wrapper": async_general_wrap,
|
168
|
-
},
|
169
|
-
{
|
170
|
-
"package": "qdrant_client",
|
171
|
-
"object": "AsyncQdrantClient.set_payload",
|
172
|
-
"endpoint": "qdrant.set_payload",
|
173
|
-
"wrapper": async_general_wrap,
|
174
|
-
},
|
175
|
-
{
|
176
|
-
"package": "qdrant_client",
|
177
|
-
"object": "AsyncQdrantClient.overwrite_payload",
|
178
|
-
"endpoint": "qdrant.overwrite_payload",
|
179
|
-
"wrapper": async_general_wrap,
|
180
|
-
},
|
181
|
-
{
|
182
|
-
"package": "qdrant_client",
|
183
|
-
"object": "AsyncQdrantClient.clear_payload",
|
184
|
-
"endpoint": "qdrant.clear_payload",
|
185
|
-
"wrapper": async_general_wrap,
|
186
|
-
},
|
187
|
-
{
|
188
|
-
"package": "qdrant_client",
|
189
|
-
"object": "AsyncQdrantClient.delete_payload",
|
190
|
-
"endpoint": "qdrant.delete_payload",
|
191
|
-
"wrapper": async_general_wrap,
|
192
|
-
},
|
193
|
-
{
|
194
|
-
"package": "qdrant_client",
|
195
|
-
"object": "AsyncQdrantClient.upload_points",
|
196
|
-
"endpoint": "qdrant.upload_points",
|
197
|
-
"wrapper": async_general_wrap,
|
198
|
-
},
|
199
|
-
{
|
200
|
-
"package": "qdrant_client",
|
201
|
-
"object": "AsyncQdrantClient.update_vectors",
|
202
|
-
"endpoint": "qdrant.update_vectors",
|
203
|
-
"wrapper": async_general_wrap,
|
204
|
-
},
|
205
|
-
{
|
206
|
-
"package": "qdrant_client",
|
207
|
-
"object": "AsyncQdrantClient.delete_vectors",
|
208
|
-
"endpoint": "qdrant.delete_vectors",
|
209
|
-
"wrapper": async_general_wrap,
|
210
|
-
},
|
211
|
-
{
|
212
|
-
"package": "qdrant_client",
|
213
|
-
"object": "AsyncQdrantClient.delete",
|
214
|
-
"endpoint": "qdrant.delete",
|
215
|
-
"wrapper": async_general_wrap,
|
216
|
-
},
|
217
|
-
{
|
218
|
-
"package": "qdrant_client",
|
219
|
-
"object": "AsyncQdrantClient.retrieve",
|
220
|
-
"endpoint": "qdrant.retrieve",
|
221
|
-
"wrapper": async_general_wrap,
|
222
|
-
},
|
223
|
-
{
|
224
|
-
"package": "qdrant_client",
|
225
|
-
"object": "AsyncQdrantClient.scroll",
|
226
|
-
"endpoint": "qdrant.scroll",
|
227
|
-
"wrapper": async_general_wrap,
|
228
|
-
},
|
229
|
-
{
|
230
|
-
"package": "qdrant_client",
|
231
|
-
"object": "AsyncQdrantClient.search",
|
232
|
-
"endpoint": "qdrant.search",
|
233
|
-
"wrapper": async_general_wrap,
|
234
|
-
},
|
235
|
-
{
|
236
|
-
"package": "qdrant_client",
|
237
|
-
"object": "AsyncQdrantClient.search_groups",
|
238
|
-
"endpoint": "qdrant.search_groups",
|
239
|
-
"wrapper": async_general_wrap,
|
240
|
-
},
|
241
|
-
{
|
242
|
-
|
243
|
-
"package": "qdrant_client",
|
244
|
-
"object": "AsyncQdrantClient.recommend",
|
245
|
-
"endpoint": "qdrant.recommend",
|
246
|
-
"wrapper": async_general_wrap,
|
247
|
-
},
|
248
|
-
{
|
249
|
-
|
250
|
-
"package": "qdrant_client",
|
251
|
-
"object": "AsyncQdrantClient.create_payload_index",
|
252
|
-
"endpoint": "qdrant.create_payload_index",
|
253
|
-
"wrapper": async_general_wrap,
|
254
|
-
},
|
255
|
-
{
|
256
|
-
|
257
|
-
"package": "qdrant_client",
|
258
|
-
"object": "AsyncQdrantClient.query_points",
|
259
|
-
"endpoint": "qdrant.query_points",
|
260
|
-
"wrapper": async_general_wrap,
|
261
|
-
},
|
15
|
+
# Operations to wrap for both sync and async clients
|
16
|
+
QDRANT_OPERATIONS = [
|
17
|
+
("create_collection", "qdrant.create_collection"),
|
18
|
+
("delete_collection", "qdrant.delete_collection"),
|
19
|
+
("update_collection", "qdrant.update_collection"),
|
20
|
+
("upload_collection", "qdrant.upload_collection"),
|
21
|
+
("upsert", "qdrant.upsert"),
|
22
|
+
("set_payload", "qdrant.set_payload"),
|
23
|
+
("overwrite_payload", "qdrant.overwrite_payload"),
|
24
|
+
("clear_payload", "qdrant.clear_payload"),
|
25
|
+
("delete_payload", "qdrant.delete_payload"),
|
26
|
+
("upload_points", "qdrant.upload_points"),
|
27
|
+
("update_vectors", "qdrant.update_vectors"),
|
28
|
+
("delete_vectors", "qdrant.delete_vectors"),
|
29
|
+
("delete", "qdrant.delete"),
|
30
|
+
("retrieve", "qdrant.retrieve"),
|
31
|
+
("scroll", "qdrant.scroll"),
|
32
|
+
("search", "qdrant.search"),
|
33
|
+
("search_groups", "qdrant.search_groups"),
|
34
|
+
("recommend", "qdrant.recommend"),
|
35
|
+
("create_payload_index", "qdrant.create_payload_index"),
|
36
|
+
("query_points", "qdrant.query_points"),
|
262
37
|
]
|
263
38
|
|
264
39
|
class QdrantInstrumentor(BaseInstrumentor):
|
265
|
-
"""
|
40
|
+
"""
|
41
|
+
An instrumentor for Qdrant client library.
|
42
|
+
"""
|
266
43
|
|
267
44
|
def instrumentation_dependencies(self) -> Collection[str]:
|
268
45
|
return _instruments
|
269
46
|
|
270
47
|
def _instrument(self, **kwargs):
|
271
|
-
|
272
|
-
environment = kwargs.get("environment")
|
48
|
+
version = importlib.metadata.version("qdrant-client")
|
49
|
+
environment = kwargs.get("environment", "default")
|
50
|
+
application_name = kwargs.get("application_name", "default")
|
273
51
|
tracer = kwargs.get("tracer")
|
52
|
+
pricing_info = kwargs.get("pricing_info", {})
|
53
|
+
capture_message_content = kwargs.get("capture_message_content", False)
|
274
54
|
metrics = kwargs.get("metrics_dict")
|
275
|
-
pricing_info = kwargs.get("pricing_info")
|
276
|
-
capture_message_content = kwargs.get("capture_message_content")
|
277
55
|
disable_metrics = kwargs.get("disable_metrics")
|
278
|
-
version = importlib.metadata.version("qdrant-client")
|
279
56
|
|
280
|
-
|
281
|
-
|
282
|
-
wrap_object = wrapped_method.get("object")
|
283
|
-
gen_ai_endpoint = wrapped_method.get("endpoint")
|
284
|
-
wrapper = wrapped_method.get("wrapper")
|
57
|
+
# Wrap sync operations
|
58
|
+
for method_name, endpoint in QDRANT_OPERATIONS:
|
285
59
|
wrap_function_wrapper(
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
60
|
+
"qdrant_client",
|
61
|
+
f"QdrantClient.{method_name}",
|
62
|
+
general_wrap(
|
63
|
+
endpoint, version, environment, application_name, tracer,
|
64
|
+
pricing_info, capture_message_content, metrics, disable_metrics
|
65
|
+
),
|
290
66
|
)
|
291
67
|
|
68
|
+
# Wrap async operations
|
69
|
+
for method_name, endpoint in QDRANT_OPERATIONS:
|
70
|
+
wrap_function_wrapper(
|
71
|
+
"qdrant_client",
|
72
|
+
f"AsyncQdrantClient.{method_name}",
|
73
|
+
async_general_wrap(
|
74
|
+
endpoint, version, environment, application_name, tracer,
|
75
|
+
pricing_info, capture_message_content, metrics, disable_metrics
|
76
|
+
),
|
77
|
+
)
|
292
78
|
|
293
|
-
@staticmethod
|
294
79
|
def _uninstrument(self, **kwargs):
|
295
80
|
pass
|
@@ -1,267 +1,55 @@
|
|
1
1
|
# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment, too-many-branches
|
2
2
|
"""
|
3
|
-
Module for monitoring Qdrant.
|
3
|
+
Module for monitoring Qdrant async operations.
|
4
4
|
"""
|
5
5
|
|
6
|
-
import
|
7
|
-
from opentelemetry.trace import SpanKind
|
8
|
-
from opentelemetry
|
6
|
+
import time
|
7
|
+
from opentelemetry.trace import SpanKind
|
8
|
+
from opentelemetry import context as context_api
|
9
9
|
from openlit.__helpers import handle_exception
|
10
|
-
from openlit.
|
10
|
+
from openlit.instrumentation.qdrant.utils import DB_OPERATION_MAP, process_qdrant_response, set_server_address_and_port
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def object_count(obj):
|
16
|
-
"""
|
17
|
-
Counts Length of object if it exists, Else returns None
|
18
|
-
"""
|
19
|
-
try:
|
20
|
-
cnt = len(obj)
|
21
|
-
# pylint: disable=bare-except
|
22
|
-
except:
|
23
|
-
cnt = 0
|
24
|
-
|
25
|
-
return cnt
|
26
|
-
|
27
|
-
def async_general_wrap(gen_ai_endpoint, version, environment, application_name,
|
28
|
-
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
12
|
+
def async_general_wrap(gen_ai_endpoint, version, environment, application_name, tracer,
|
13
|
+
pricing_info, capture_message_content, metrics, disable_metrics):
|
29
14
|
"""
|
30
|
-
|
31
|
-
|
32
|
-
This function wraps any given function to measure its execution time,
|
33
|
-
log its operation, and trace its execution using OpenTelemetry.
|
34
|
-
|
35
|
-
Parameters:
|
36
|
-
- gen_ai_endpoint (str): A descriptor or name for the endpoint being traced.
|
37
|
-
- version (str): The version of the Langchain application.
|
38
|
-
- environment (str): The deployment environment (e.g., 'production', 'development').
|
39
|
-
- application_name (str): Name of the Langchain application.
|
40
|
-
- tracer (opentelemetry.trace.Tracer): The tracer object used for OpenTelemetry tracing.
|
41
|
-
- pricing_info (dict): Information about the pricing for internal metrics (currently not used).
|
42
|
-
- capture_message_content (bool): Flag indicating whether to trace the content of the response.
|
43
|
-
|
44
|
-
Returns:
|
45
|
-
- function: A higher-order function that takes a function 'wrapped' and returns
|
46
|
-
a new function that wraps 'wrapped' with additional tracing and logging.
|
15
|
+
Generates a telemetry wrapper for Pinecone function calls.
|
47
16
|
"""
|
48
17
|
|
49
18
|
async def wrapper(wrapped, instance, args, kwargs):
|
50
19
|
"""
|
51
|
-
|
52
|
-
time, and records trace data using OpenTelemetry.
|
53
|
-
|
54
|
-
Parameters:
|
55
|
-
- wrapped (Callable): The original function that this wrapper will execute.
|
56
|
-
- instance (object): The instance to which the wrapped function belongs. This
|
57
|
-
is used for instance methods. For static and classmethods,
|
58
|
-
this may be None.
|
59
|
-
- args (tuple): Positional arguments passed to the wrapped function.
|
60
|
-
- kwargs (dict): Keyword arguments passed to the wrapped function.
|
61
|
-
|
62
|
-
Returns:
|
63
|
-
- The result of the wrapped function call.
|
64
|
-
|
65
|
-
The wrapper initiates a span with the provided tracer, sets various attributes
|
66
|
-
on the span based on the function's execution and response, and ensures
|
67
|
-
errors are handled and logged appropriately.
|
20
|
+
Wraps the Qdrant async operation with tracing and logging.
|
68
21
|
"""
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
try:
|
73
|
-
span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
|
74
|
-
span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT,
|
75
|
-
gen_ai_endpoint)
|
76
|
-
span.set_attribute(DEPLOYMENT_ENVIRONMENT,
|
77
|
-
environment)
|
78
|
-
span.set_attribute(SERVICE_NAME,
|
79
|
-
application_name)
|
80
|
-
span.set_attribute(SemanticConvention.GEN_AI_OPERATION,
|
81
|
-
SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB)
|
82
|
-
span.set_attribute(SemanticConvention.DB_SYSTEM_NAME,
|
83
|
-
SemanticConvention.DB_SYSTEM_QDRANT)
|
84
|
-
|
85
|
-
if gen_ai_endpoint == "qdrant.create_collection":
|
86
|
-
db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
|
87
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
88
|
-
SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
|
89
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
90
|
-
kwargs.get("collection_name", ""))
|
91
|
-
|
92
|
-
elif gen_ai_endpoint == "qdrant.upload_collection":
|
93
|
-
db_operation = SemanticConvention.DB_OPERATION_CREATE_COLLECTION
|
94
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
95
|
-
SemanticConvention.DB_OPERATION_CREATE_COLLECTION)
|
96
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
97
|
-
kwargs.get("collection_name", ""))
|
98
|
-
|
99
|
-
elif gen_ai_endpoint == "qdrant.delete_collection":
|
100
|
-
db_operation = SemanticConvention.DB_OPERATION_DELETE_COLLECTION
|
101
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
102
|
-
SemanticConvention.DB_OPERATION_DELETE_COLLECTION)
|
103
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
104
|
-
kwargs.get("collection_name", ""))
|
22
|
+
# CRITICAL: Suppression check
|
23
|
+
if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
|
24
|
+
return await wrapped(*args, **kwargs)
|
105
25
|
|
106
|
-
|
107
|
-
|
108
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
109
|
-
SemanticConvention.DB_OPERATION_UPDATE_COLLECTION)
|
110
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
111
|
-
kwargs.get("collection_name", ""))
|
26
|
+
# Extract operation from endpoint
|
27
|
+
db_operation = DB_OPERATION_MAP.get(gen_ai_endpoint, "unknown")
|
112
28
|
|
113
|
-
|
114
|
-
|
115
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
116
|
-
SemanticConvention.DB_OPERATION_ADD)
|
117
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
118
|
-
kwargs.get("collection_name", ""))
|
119
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
|
120
|
-
response.status)
|
121
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
122
|
-
object_count(kwargs.get("points", [])))
|
123
|
-
span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT,
|
124
|
-
object_count(kwargs.get("payload", [])))
|
29
|
+
# Server address calculation
|
30
|
+
server_address, server_port = set_server_address_and_port(instance)
|
125
31
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
SemanticConvention.DB_OPERATION_QUERY)
|
130
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
131
|
-
kwargs.get("collection_name", ""))
|
132
|
-
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
133
|
-
str(kwargs.get("ids", "")))
|
32
|
+
# Span naming: use operation + collection
|
33
|
+
collection_name = kwargs.get("collection_name", "unknown")
|
34
|
+
span_name = f"{db_operation} {collection_name}"
|
134
35
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
140
|
-
kwargs.get("collection_name", ""))
|
141
|
-
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
142
|
-
str(kwargs.get("scroll_filter", "")))
|
143
|
-
|
144
|
-
elif gen_ai_endpoint in ["qdrant.search", "qdrant.search_groups"]:
|
145
|
-
db_operation = SemanticConvention.DB_OPERATION_QUERY
|
146
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
147
|
-
SemanticConvention.DB_OPERATION_QUERY)
|
148
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
149
|
-
kwargs.get("collection_name", ""))
|
150
|
-
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
151
|
-
str(kwargs.get("query_vector", "")))
|
152
|
-
|
153
|
-
elif gen_ai_endpoint == "qdrant.recommend":
|
154
|
-
db_operation = SemanticConvention.DB_OPERATION_QUERY
|
155
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
156
|
-
SemanticConvention.DB_OPERATION_QUERY)
|
157
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
158
|
-
kwargs.get("collection_name", ""))
|
159
|
-
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
160
|
-
"positive:" + str(kwargs.get("positive", "")) +
|
161
|
-
" negative:" + str(kwargs.get("negative", "")))
|
162
|
-
|
163
|
-
elif gen_ai_endpoint == "qdrant.upload_points":
|
164
|
-
db_operation = SemanticConvention.DB_OPERATION_ADD
|
165
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
166
|
-
SemanticConvention.DB_OPERATION_ADD)
|
167
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
168
|
-
kwargs.get("collection_name", ""))
|
169
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
170
|
-
object_count(kwargs.get("points")))
|
171
|
-
|
172
|
-
elif gen_ai_endpoint == "qdrant.update_vectors":
|
173
|
-
db_operation = SemanticConvention.DB_OPERATION_UPDATE
|
174
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
175
|
-
SemanticConvention.DB_OPERATION_UPDATE)
|
176
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
177
|
-
kwargs.get("collection_name", ""))
|
178
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
|
179
|
-
response.status)
|
180
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
181
|
-
object_count(kwargs.get("points")))
|
182
|
-
|
183
|
-
elif gen_ai_endpoint == "qdrant.overwrite_payload":
|
184
|
-
db_operation = SemanticConvention.DB_OPERATION_UPDATE
|
185
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
186
|
-
SemanticConvention.DB_OPERATION_UPDATE)
|
187
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
188
|
-
kwargs.get("collection_name", ""))
|
189
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
|
190
|
-
response.status)
|
191
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
192
|
-
object_count(kwargs.get("points")))
|
193
|
-
span.set_attribute(SemanticConvention.DB_PAYLOAD_COUNT,
|
194
|
-
object_count(kwargs.get("payload")))
|
195
|
-
|
196
|
-
elif gen_ai_endpoint == "qdrant.upsert":
|
197
|
-
db_operation = SemanticConvention.DB_OPERATION_UPSERT
|
198
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
199
|
-
kwargs.get("collection_name", ""))
|
200
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
201
|
-
SemanticConvention.DB_OPERATION_UPSERT)
|
202
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
|
203
|
-
response.status)
|
204
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
205
|
-
object_count(kwargs.get("points")))
|
206
|
-
|
207
|
-
elif gen_ai_endpoint in ["qdrant.delete_payload", "qdrant.delete_vectors"]:
|
208
|
-
db_operation = SemanticConvention.DB_OPERATION_DELETE
|
209
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
210
|
-
SemanticConvention.DB_OPERATION_DELETE)
|
211
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
212
|
-
kwargs.get("collection_name", ""))
|
213
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
|
214
|
-
response.status)
|
215
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
216
|
-
object_count(kwargs.get("points")))
|
217
|
-
|
218
|
-
elif gen_ai_endpoint in ["qdrant.clear_payload", "qdrant.delete"]:
|
219
|
-
db_operation = SemanticConvention.DB_OPERATION_DELETE
|
220
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
221
|
-
SemanticConvention.DB_OPERATION_DELETE)
|
222
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
223
|
-
kwargs.get("collection_name", ""))
|
224
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_STATUS,
|
225
|
-
response.status)
|
226
|
-
span.set_attribute(SemanticConvention.DB_VECTOR_COUNT,
|
227
|
-
object_count(kwargs.get("points_selector")))
|
228
|
-
|
229
|
-
elif gen_ai_endpoint == "qdrant.create_payload_index":
|
230
|
-
db_operation = SemanticConvention.DB_OPERATION_CREATE_INDEX
|
231
|
-
span.set_attribute(SemanticConvention.DB_OPERATION_NAME,
|
232
|
-
SemanticConvention.DB_OPERATION_CREATE_INDEX)
|
233
|
-
span.set_attribute(SemanticConvention.DB_COLLECTION_NAME,
|
234
|
-
kwargs.get("collection_name", ""))
|
235
|
-
span.set_attribute(SemanticConvention.DB_STATEMENT,
|
236
|
-
str(kwargs.get("query", "")))
|
237
|
-
|
238
|
-
span.set_status(Status(StatusCode.OK))
|
239
|
-
|
240
|
-
if disable_metrics is False:
|
241
|
-
attributes = {
|
242
|
-
TELEMETRY_SDK_NAME:
|
243
|
-
"openlit",
|
244
|
-
SERVICE_NAME:
|
245
|
-
application_name,
|
246
|
-
SemanticConvention.DB_SYSTEM_NAME:
|
247
|
-
SemanticConvention.DB_SYSTEM_QDRANT,
|
248
|
-
DEPLOYMENT_ENVIRONMENT:
|
249
|
-
environment,
|
250
|
-
SemanticConvention.GEN_AI_OPERATION:
|
251
|
-
SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
|
252
|
-
SemanticConvention.DB_OPERATION_NAME:
|
253
|
-
db_operation
|
254
|
-
}
|
255
|
-
|
256
|
-
metrics["db_requests"].add(1, attributes)
|
36
|
+
# CRITICAL: Use tracer.start_as_current_span() for proper context
|
37
|
+
with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
|
38
|
+
start_time = time.time()
|
39
|
+
response = await wrapped(*args, **kwargs)
|
257
40
|
|
258
|
-
|
41
|
+
try:
|
42
|
+
# Process response with endpoint information
|
43
|
+
response = process_qdrant_response(
|
44
|
+
response, db_operation, server_address, server_port,
|
45
|
+
environment, application_name, metrics, start_time, span,
|
46
|
+
capture_message_content, disable_metrics, version,
|
47
|
+
instance=instance, args=args, endpoint=gen_ai_endpoint, **kwargs
|
48
|
+
)
|
259
49
|
|
260
50
|
except Exception as e:
|
261
51
|
handle_exception(span, e)
|
262
|
-
logger.error("Error in trace creation: %s", e)
|
263
52
|
|
264
|
-
|
265
|
-
return response
|
53
|
+
return response
|
266
54
|
|
267
55
|
return wrapper
|