openlit 1.32.2__py3-none-any.whl → 1.32.3__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/__init__.py CHANGED
@@ -48,6 +48,7 @@ from openlit.instrumentation.chroma import ChromaInstrumentor
48
48
  from openlit.instrumentation.pinecone import PineconeInstrumentor
49
49
  from openlit.instrumentation.qdrant import QdrantInstrumentor
50
50
  from openlit.instrumentation.milvus import MilvusInstrumentor
51
+ from openlit.instrumentation.astra import AstraInstrumentor
51
52
  from openlit.instrumentation.transformers import TransformersInstrumentor
52
53
  from openlit.instrumentation.litellm import LiteLLMInstrumentor
53
54
  from openlit.instrumentation.crewai import CrewAIInstrumentor
@@ -250,6 +251,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
250
251
  "reka-api": "reka",
251
252
  "premai": "premai",
252
253
  "julep": "julep",
254
+ "astra": "astrapy",
253
255
  }
254
256
 
255
257
  invalid_instrumentors = [
@@ -339,6 +341,7 @@ def init(environment="default", application_name="default", tracer=None, otlp_en
339
341
  "reka-api": RekaInstrumentor(),
340
342
  "premai": PremAIInstrumentor(),
341
343
  "julep": JulepInstrumentor(),
344
+ "astra": AstraInstrumentor(),
342
345
  }
343
346
 
344
347
  # Initialize and instrument only the enabled instrumentors
@@ -0,0 +1,179 @@
1
+ # pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
2
+ """Initializer of Auto Instrumentation of AstraDB Functions"""
3
+ from typing import Collection
4
+ import importlib.metadata
5
+ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
6
+ from wrapt import wrap_function_wrapper
7
+
8
+ from openlit.instrumentation.astra.astra import general_wrap
9
+ # from openlit.instrumentation.astra.async_astra import asyc_general_wrap
10
+
11
+ _instruments = ("astrapy >= 1.5.2",)
12
+
13
+ class AstraInstrumentor(BaseInstrumentor):
14
+ """An instrumentor for AstraDB's client library."""
15
+
16
+ def instrumentation_dependencies(self) -> Collection[str]:
17
+ return _instruments
18
+
19
+ def _instrument(self, **kwargs):
20
+ application_name = kwargs.get("application_name")
21
+ environment = kwargs.get("environment")
22
+ tracer = kwargs.get("tracer")
23
+ metrics = kwargs.get("metrics_dict")
24
+ pricing_info = kwargs.get("pricing_info")
25
+ trace_content = kwargs.get("trace_content")
26
+ disable_metrics = kwargs.get("disable_metrics")
27
+ version = importlib.metadata.version("astrapy")
28
+
29
+ # Sync
30
+ wrap_function_wrapper(
31
+ "astrapy.database",
32
+ "Database.create_collection",
33
+ general_wrap("astra.create_collection", version, environment, application_name,
34
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
35
+ )
36
+ wrap_function_wrapper(
37
+ "astrapy.database",
38
+ "Database.drop_collection",
39
+ general_wrap("astra.drop_collection", version, environment, application_name,
40
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
41
+ )
42
+ wrap_function_wrapper(
43
+ "astrapy.collection",
44
+ "Collection.insert_one",
45
+ general_wrap("astra.insert_one", version, environment, application_name,
46
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
47
+ )
48
+ wrap_function_wrapper(
49
+ "astrapy.collection",
50
+ "Collection.insert_many",
51
+ general_wrap("astra.insert_many", version, environment, application_name,
52
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
53
+ )
54
+ wrap_function_wrapper(
55
+ "astrapy.collection",
56
+ "Collection.update_one",
57
+ general_wrap("astra.update_one", version, environment, application_name,
58
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
59
+ )
60
+ wrap_function_wrapper(
61
+ "astrapy.collection",
62
+ "Collection.update_many",
63
+ general_wrap("astra.update_many", version, environment, application_name,
64
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
65
+ )
66
+ wrap_function_wrapper(
67
+ "astrapy.collection",
68
+ "Collection.find_one_and_update",
69
+ general_wrap("astra.find_one_and_update", version, environment, application_name,
70
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
71
+ )
72
+ wrap_function_wrapper(
73
+ "astrapy.collection",
74
+ "Collection.find",
75
+ general_wrap("astra.find", version, environment, application_name,
76
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
77
+ )
78
+ wrap_function_wrapper(
79
+ "astrapy.collection",
80
+ "Collection.replace_one",
81
+ general_wrap("astra.replace_one", version, environment, application_name,
82
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
83
+ )
84
+ wrap_function_wrapper(
85
+ "astrapy.collection",
86
+ "Collection.find_one_and_delete",
87
+ general_wrap("astra.find_one_and_delete", version, environment, application_name,
88
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
89
+ )
90
+ wrap_function_wrapper(
91
+ "astrapy.collection",
92
+ "Collection.delete_one",
93
+ general_wrap("astra.delete_one", version, environment, application_name,
94
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
95
+ )
96
+ wrap_function_wrapper(
97
+ "astrapy.collection",
98
+ "Collection.delete_many",
99
+ general_wrap("astra.delete_many", version, environment, application_name,
100
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
101
+ )
102
+
103
+ # ASync
104
+ wrap_function_wrapper(
105
+ "astrapy.database",
106
+ "AsyncDatabase.create_collection",
107
+ general_wrap("astra.create_collection", version, environment, application_name,
108
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
109
+ )
110
+ wrap_function_wrapper(
111
+ "astrapy.database",
112
+ "AsyncDatabase.drop_collection",
113
+ general_wrap("astra.drop_collection", version, environment, application_name,
114
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
115
+ )
116
+ wrap_function_wrapper(
117
+ "astrapy.collection",
118
+ "AsyncCollection.insert_one",
119
+ general_wrap("astra.insert_one", version, environment, application_name,
120
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
121
+ )
122
+ wrap_function_wrapper(
123
+ "astrapy.collection",
124
+ "AsyncCollection.insert_many",
125
+ general_wrap("astra.insert_many", version, environment, application_name,
126
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
127
+ )
128
+ wrap_function_wrapper(
129
+ "astrapy.collection",
130
+ "AsyncCollection.update_one",
131
+ general_wrap("astra.update_one", version, environment, application_name,
132
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
133
+ )
134
+ wrap_function_wrapper(
135
+ "astrapy.collection",
136
+ "AsyncCollection.update_many",
137
+ general_wrap("astra.update_many", version, environment, application_name,
138
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
139
+ )
140
+ wrap_function_wrapper(
141
+ "astrapy.collection",
142
+ "AsyncCollection.find_one_and_update",
143
+ general_wrap("astra.find_one_and_update", version, environment, application_name,
144
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
145
+ )
146
+ wrap_function_wrapper(
147
+ "astrapy.collection",
148
+ "AsyncCollection.find",
149
+ general_wrap("astra.find", version, environment, application_name,
150
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
151
+ )
152
+ wrap_function_wrapper(
153
+ "astrapy.collection",
154
+ "AsyncCollection.replace_one",
155
+ general_wrap("astra.replace_one", version, environment, application_name,
156
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
157
+ )
158
+ wrap_function_wrapper(
159
+ "astrapy.collection",
160
+ "AsyncCollection.find_one_and_delete",
161
+ general_wrap("astra.find_one_and_delete", version, environment, application_name,
162
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
163
+ )
164
+ wrap_function_wrapper(
165
+ "astrapy.collection",
166
+ "AsyncCollection.delete_one",
167
+ general_wrap("astra.delete_one", version, environment, application_name,
168
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
169
+ )
170
+ wrap_function_wrapper(
171
+ "astrapy.collection",
172
+ "AsyncCollection.delete_many",
173
+ general_wrap("astra.delete_many", version, environment, application_name,
174
+ tracer, pricing_info, trace_content, metrics, disable_metrics),
175
+ )
176
+
177
+ @staticmethod
178
+ def _uninstrument(self, **kwargs):
179
+ pass
@@ -0,0 +1,226 @@
1
+ # pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment, too-many-branches
2
+ """
3
+ Module for monitoring AstraDB.
4
+ """
5
+
6
+ import logging
7
+ from opentelemetry.trace import SpanKind, Status, StatusCode
8
+ from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
9
+ from openlit.__helpers import handle_exception
10
+ from openlit.semcov import SemanticConvetion
11
+
12
+ # Initialize logger for logging potential issues and operations
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def object_count(obj):
16
+ """
17
+ Counts Length of object if it exists, Else returns None
18
+ """
19
+
20
+ return len(obj) if obj else None
21
+
22
+ def general_wrap(gen_ai_endpoint, version, environment, application_name,
23
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
24
+ """
25
+ Wraps a AstraDB operation to trace and log its execution metrics.
26
+
27
+ This function is intended to wrap around AstraDB operations in order to
28
+ measure their execution time, log relevant information, and trace the execution
29
+ using OpenTelemetry. This helps in monitoring and debugging operations within
30
+ the AstraDB space.
31
+
32
+ Parameters:
33
+ - operation (str): The specific AstraDB operation being monitored.
34
+ Examples include 'create_index', 'query', 'upsert', etc.
35
+ - version (str): The version of the application interfacing with AstraDB.
36
+ - environment (str): The deployment environment, such as 'production' or 'development'.
37
+ - application_name (str): The name of the application performing the AstraDB operation.
38
+ - tracer (opentelemetry.trace.Tracer): An object used for OpenTelemetry tracing.
39
+ - pricing_info (dict): Information about pricing, not used in current implementation.
40
+ - trace_content (bool): A flag indicating whether the content of responses should be traced.
41
+
42
+ Returns:
43
+ - function: A decorator function that, when applied, wraps the target function with
44
+ additional functionality for tracing and logging AstraDB operations.
45
+ """
46
+
47
+ def wrapper(wrapped, instance, args, kwargs):
48
+ """
49
+ Executes the wrapped AstraDB operation, adding tracing and logging.
50
+
51
+ This inner wrapper function captures the execution of AstraDB operations,
52
+ annotating the operation with relevant metrics and tracing information, and
53
+ ensuring any exceptions are caught and logged appropriately.
54
+
55
+ Parameters:
56
+ - wrapped (Callable): The AstraDB operation to be wrapped and executed.
57
+ - instance (object): The instance on which the operation is called (for class methods).
58
+ - args (tuple): Positional arguments for the AstraDB operation.
59
+ - kwargs (dict): Keyword arguments for the AstraDB operation.
60
+
61
+ Returns:
62
+ - Any: The result of executing the wrapped AstraDB operation.
63
+ """
64
+
65
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
66
+ response = wrapped(*args, **kwargs)
67
+
68
+ try:
69
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
70
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
71
+ gen_ai_endpoint)
72
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
73
+ environment)
74
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
75
+ application_name)
76
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
77
+ SemanticConvetion.GEN_AI_TYPE_VECTORDB)
78
+ span.set_attribute(SemanticConvetion.DB_SYSTEM,
79
+ SemanticConvetion.DB_SYSTEM_ASTRA)
80
+
81
+ if gen_ai_endpoint == "astra.create_collection":
82
+ db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
83
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
84
+ db_operation)
85
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
86
+ response.name)
87
+ span.set_attribute(SemanticConvetion.DB_INDEX_DIMENSION,
88
+ kwargs.get("dimension", ""))
89
+ span.set_attribute(SemanticConvetion.DB_INDEX_METRIC,
90
+ kwargs.get("metric", ""))
91
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
92
+ instance.api_endpoint)
93
+
94
+ elif gen_ai_endpoint == "astra.drop_collection":
95
+ db_operation = SemanticConvetion.DB_OPERATION_DELETE_COLLECTION
96
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
97
+ db_operation)
98
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
99
+ kwargs.get("name_or_collection", ""))
100
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
101
+ instance.api_endpoint)
102
+
103
+ elif gen_ai_endpoint == "astra.insert_one":
104
+ db_operation = SemanticConvetion.DB_OPERATION_INSERT
105
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
106
+ db_operation)
107
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
108
+ instance.name)
109
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
110
+ 1)
111
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
112
+ instance.database.api_endpoint)
113
+ span.set_attribute(SemanticConvetion.DB_OPERATION_ID,
114
+ response.inserted_id)
115
+
116
+ elif gen_ai_endpoint == "astra.insert_many":
117
+ db_operation = SemanticConvetion.DB_OPERATION_INSERT
118
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
119
+ db_operation)
120
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
121
+ object_count(args[0]))
122
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
123
+ instance.name)
124
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
125
+ instance.database.api_endpoint)
126
+
127
+ elif gen_ai_endpoint in ["astra.update_one", "astra.update_many"]:
128
+ db_operation = SemanticConvetion.DB_OPERATION_UPDATE
129
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
130
+ db_operation)
131
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
132
+ instance.name)
133
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
134
+ instance.database.api_endpoint)
135
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
136
+ response.update_info.get("nModified", 0))
137
+
138
+ elif gen_ai_endpoint == "astra.find_one_and_update":
139
+ db_operation = SemanticConvetion.DB_OPERATION_UPDATE
140
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
141
+ db_operation)
142
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
143
+ instance.name)
144
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
145
+ instance.database.api_endpoint)
146
+
147
+ elif gen_ai_endpoint == "astra.find":
148
+ db_operation = SemanticConvetion.DB_OPERATION_QUERY
149
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
150
+ db_operation)
151
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
152
+ instance.name)
153
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
154
+ instance.database.api_endpoint)
155
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
156
+ str(args))
157
+
158
+ elif gen_ai_endpoint == "astra.replace_one":
159
+ if kwargs.get("upsert") is True:
160
+ db_operation = SemanticConvetion.DB_OPERATION_UPSERT
161
+ else:
162
+ db_operation = SemanticConvetion.DB_OPERATION_REPLACE
163
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
164
+ db_operation)
165
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
166
+ instance.name)
167
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
168
+ instance.database.api_endpoint)
169
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
170
+ str(args))
171
+
172
+ elif gen_ai_endpoint in ["astra.delete_one", "astra.delete_many"]:
173
+ db_operation = SemanticConvetion.DB_OPERATION_DELETE
174
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
175
+ db_operation)
176
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
177
+ instance.name)
178
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
179
+ instance.database.api_endpoint)
180
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
181
+ str(args))
182
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
183
+ response.deleted_count)
184
+
185
+ elif gen_ai_endpoint == "astra.find_one_and_delete":
186
+ db_operation = SemanticConvetion.DB_OPERATION_DELETE
187
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
188
+ db_operation)
189
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
190
+ instance.name)
191
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
192
+ instance.database.api_endpoint)
193
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
194
+ str(args))
195
+
196
+ span.set_status(Status(StatusCode.OK))
197
+
198
+ if disable_metrics is False:
199
+ attributes = {
200
+ TELEMETRY_SDK_NAME:
201
+ "openlit",
202
+ SemanticConvetion.GEN_AI_APPLICATION_NAME:
203
+ application_name,
204
+ SemanticConvetion.DB_SYSTEM:
205
+ SemanticConvetion.DB_SYSTEM_ASTRA,
206
+ SemanticConvetion.GEN_AI_ENVIRONMENT:
207
+ environment,
208
+ SemanticConvetion.GEN_AI_TYPE:
209
+ SemanticConvetion.GEN_AI_TYPE_VECTORDB,
210
+ SemanticConvetion.DB_OPERATION:
211
+ db_operation
212
+ }
213
+
214
+ metrics["db_requests"].add(1, attributes)
215
+
216
+ # Return original response
217
+ return response
218
+
219
+ except Exception as e:
220
+ handle_exception(span, e)
221
+ logger.error("Error in trace creation: %s", e)
222
+
223
+ # Return original response
224
+ return response
225
+
226
+ return wrapper
@@ -0,0 +1,226 @@
1
+ # pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument, possibly-used-before-assignment, too-many-branches
2
+ """
3
+ Module for monitoring AstraDB.
4
+ """
5
+
6
+ import logging
7
+ from opentelemetry.trace import SpanKind, Status, StatusCode
8
+ from opentelemetry.sdk.resources import TELEMETRY_SDK_NAME
9
+ from openlit.__helpers import handle_exception
10
+ from openlit.semcov import SemanticConvetion
11
+
12
+ # Initialize logger for logging potential issues and operations
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def object_count(obj):
16
+ """
17
+ Counts Length of object if it exists, Else returns None
18
+ """
19
+
20
+ return len(obj) if obj else None
21
+
22
+ def general_wrap(gen_ai_endpoint, version, environment, application_name,
23
+ tracer, pricing_info, trace_content, metrics, disable_metrics):
24
+ """
25
+ Wraps a AstraDB operation to trace and log its execution metrics.
26
+
27
+ This function is intended to wrap around AstraDB operations in order to
28
+ measure their execution time, log relevant information, and trace the execution
29
+ using OpenTelemetry. This helps in monitoring and debugging operations within
30
+ the AstraDB space.
31
+
32
+ Parameters:
33
+ - operation (str): The specific AstraDB operation being monitored.
34
+ Examples include 'create_index', 'query', 'upsert', etc.
35
+ - version (str): The version of the application interfacing with AstraDB.
36
+ - environment (str): The deployment environment, such as 'production' or 'development'.
37
+ - application_name (str): The name of the application performing the AstraDB operation.
38
+ - tracer (opentelemetry.trace.Tracer): An object used for OpenTelemetry tracing.
39
+ - pricing_info (dict): Information about pricing, not used in current implementation.
40
+ - trace_content (bool): A flag indicating whether the content of responses should be traced.
41
+
42
+ Returns:
43
+ - function: A decorator function that, when applied, wraps the target function with
44
+ additional functionality for tracing and logging AstraDB operations.
45
+ """
46
+
47
+ async def wrapper(wrapped, instance, args, kwargs):
48
+ """
49
+ Executes the wrapped AstraDB operation, adding tracing and logging.
50
+
51
+ This inner wrapper function captures the execution of AstraDB operations,
52
+ annotating the operation with relevant metrics and tracing information, and
53
+ ensuring any exceptions are caught and logged appropriately.
54
+
55
+ Parameters:
56
+ - wrapped (Callable): The AstraDB operation to be wrapped and executed.
57
+ - instance (object): The instance on which the operation is called (for class methods).
58
+ - args (tuple): Positional arguments for the AstraDB operation.
59
+ - kwargs (dict): Keyword arguments for the AstraDB operation.
60
+
61
+ Returns:
62
+ - Any: The result of executing the wrapped AstraDB operation.
63
+ """
64
+
65
+ with tracer.start_as_current_span(gen_ai_endpoint, kind= SpanKind.CLIENT) as span:
66
+ response = await wrapped(*args, **kwargs)
67
+
68
+ try:
69
+ span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
70
+ span.set_attribute(SemanticConvetion.GEN_AI_ENDPOINT,
71
+ gen_ai_endpoint)
72
+ span.set_attribute(SemanticConvetion.GEN_AI_ENVIRONMENT,
73
+ environment)
74
+ span.set_attribute(SemanticConvetion.GEN_AI_APPLICATION_NAME,
75
+ application_name)
76
+ span.set_attribute(SemanticConvetion.GEN_AI_TYPE,
77
+ SemanticConvetion.GEN_AI_TYPE_VECTORDB)
78
+ span.set_attribute(SemanticConvetion.DB_SYSTEM,
79
+ SemanticConvetion.DB_SYSTEM_ASTRA)
80
+
81
+ if gen_ai_endpoint == "astra.create_collection":
82
+ db_operation = SemanticConvetion.DB_OPERATION_CREATE_COLLECTION
83
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
84
+ db_operation)
85
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
86
+ response.name)
87
+ span.set_attribute(SemanticConvetion.DB_INDEX_DIMENSION,
88
+ kwargs.get("dimension", ""))
89
+ span.set_attribute(SemanticConvetion.DB_INDEX_METRIC,
90
+ kwargs.get("metric", ""))
91
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
92
+ instance.api_endpoint)
93
+
94
+ elif gen_ai_endpoint == "astra.drop_collection":
95
+ db_operation = SemanticConvetion.DB_OPERATION_DELETE_COLLECTION
96
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
97
+ db_operation)
98
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
99
+ kwargs.get("name_or_collection", ""))
100
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
101
+ instance.api_endpoint)
102
+
103
+ elif gen_ai_endpoint == "astra.insert_one":
104
+ db_operation = SemanticConvetion.DB_OPERATION_INSERT
105
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
106
+ db_operation)
107
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
108
+ instance.name)
109
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
110
+ 1)
111
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
112
+ instance.database.api_endpoint)
113
+ span.set_attribute(SemanticConvetion.DB_OPERATION_ID,
114
+ response.inserted_id)
115
+
116
+ elif gen_ai_endpoint == "astra.insert_many":
117
+ db_operation = SemanticConvetion.DB_OPERATION_INSERT
118
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
119
+ db_operation)
120
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
121
+ object_count(args[0]))
122
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
123
+ instance.name)
124
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
125
+ instance.database.api_endpoint)
126
+
127
+ elif gen_ai_endpoint in ["astra.update_one", "astra.update_many"]:
128
+ db_operation = SemanticConvetion.DB_OPERATION_UPDATE
129
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
130
+ db_operation)
131
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
132
+ instance.name)
133
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
134
+ instance.database.api_endpoint)
135
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
136
+ response.update_info.get("nModified", 0))
137
+
138
+ elif gen_ai_endpoint == "astra.find_one_and_update":
139
+ db_operation = SemanticConvetion.DB_OPERATION_UPDATE
140
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
141
+ db_operation)
142
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
143
+ instance.name)
144
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
145
+ instance.database.api_endpoint)
146
+
147
+ elif gen_ai_endpoint == "astra.find":
148
+ db_operation = SemanticConvetion.DB_OPERATION_QUERY
149
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
150
+ db_operation)
151
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
152
+ instance.name)
153
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
154
+ instance.database.api_endpoint)
155
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
156
+ str(args))
157
+
158
+ elif gen_ai_endpoint == "astra.replace_one":
159
+ if kwargs.get("upsert") is True:
160
+ db_operation = SemanticConvetion.DB_OPERATION_UPSERT
161
+ else:
162
+ db_operation = SemanticConvetion.DB_OPERATION_REPLACE
163
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
164
+ db_operation)
165
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
166
+ instance.name)
167
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
168
+ instance.database.api_endpoint)
169
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
170
+ str(args))
171
+
172
+ elif gen_ai_endpoint in ["astra.delete_one", "astra.delete_many"]:
173
+ db_operation = SemanticConvetion.DB_OPERATION_DELETE
174
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
175
+ db_operation)
176
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
177
+ instance.name)
178
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
179
+ instance.database.api_endpoint)
180
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
181
+ str(args))
182
+ span.set_attribute(SemanticConvetion.DB_DOCUMENTS_COUNT,
183
+ response.deleted_count)
184
+
185
+ elif gen_ai_endpoint == "astra.find_one_and_delete":
186
+ db_operation = SemanticConvetion.DB_OPERATION_DELETE
187
+ span.set_attribute(SemanticConvetion.DB_OPERATION,
188
+ db_operation)
189
+ span.set_attribute(SemanticConvetion.DB_COLLECTION_NAME,
190
+ instance.name)
191
+ span.set_attribute(SemanticConvetion.DB_OPERATION_API_ENDPOINT,
192
+ instance.database.api_endpoint)
193
+ span.set_attribute(SemanticConvetion.DB_STATEMENT,
194
+ str(args))
195
+
196
+ span.set_status(Status(StatusCode.OK))
197
+
198
+ if disable_metrics is False:
199
+ attributes = {
200
+ TELEMETRY_SDK_NAME:
201
+ "openlit",
202
+ SemanticConvetion.GEN_AI_APPLICATION_NAME:
203
+ application_name,
204
+ SemanticConvetion.DB_SYSTEM:
205
+ SemanticConvetion.DB_SYSTEM_ASTRA,
206
+ SemanticConvetion.GEN_AI_ENVIRONMENT:
207
+ environment,
208
+ SemanticConvetion.GEN_AI_TYPE:
209
+ SemanticConvetion.GEN_AI_TYPE_VECTORDB,
210
+ SemanticConvetion.DB_OPERATION:
211
+ db_operation
212
+ }
213
+
214
+ metrics["db_requests"].add(1, attributes)
215
+
216
+ # Return original response
217
+ return response
218
+
219
+ except Exception as e:
220
+ handle_exception(span, e)
221
+ logger.error("Error in trace creation: %s", e)
222
+
223
+ # Return original response
224
+ return response
225
+
226
+ return wrapper
@@ -121,17 +121,21 @@ class SemanticConvetion:
121
121
  GEN_AI_SYSTEM_JULEP = "julep"
122
122
 
123
123
  # Vector DB
124
+ DB_OPERATION_API_ENDPOINT = "db.operation.api_endpoint"
124
125
  DB_REQUESTS = "db.total.requests"
125
126
  DB_SYSTEM = "db.system"
126
127
  DB_COLLECTION_NAME = "db.collection.name"
127
128
  DB_OPERATION = "db.operation"
129
+ DB_OPERATION_ID = "db.operation.id"
128
130
  DB_OPERATION_STATUS = "db.operation.status"
129
131
  DB_OPERATION_COST = "db.operation.cost"
130
132
  DB_OPERATION_CREATE_INDEX = "create_index"
131
133
  DB_OPERATION_CREATE_COLLECTION = "create_collection"
132
134
  DB_OPERATION_UPDATE_COLLECTION = "update_collection"
133
135
  DB_OPERATION_DELETE_COLLECTION = "delete_collection"
136
+ DB_OPERATION_INSERT = "insert"
134
137
  DB_OPERATION_QUERY = "query"
138
+ DB_OPERATION_REPLACE = "replace"
135
139
  DB_OPERATION_DELETE = "delete"
136
140
  DB_OPERATION_UPDATE = "update"
137
141
  DB_OPERATION_UPSERT = "upsert"
@@ -166,6 +170,7 @@ class SemanticConvetion:
166
170
  DB_SYSTEM_PINECONE = "pinecone"
167
171
  DB_SYSTEM_QDRANT = "qdrant"
168
172
  DB_SYSTEM_MILVUS = "milvus"
173
+ DB_SYSTEM_ASTRA = "astra"
169
174
 
170
175
  # Agents
171
176
  GEN_AI_AGENT_ID = "gen_ai.agent.id"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: openlit
3
- Version: 1.32.2
3
+ Version: 1.32.3
4
4
  Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
5
5
  Home-page: https://github.com/openlit/openlit/tree/main/openlit/python
6
6
  Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
@@ -56,7 +56,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
56
56
 
57
57
  ## ⚡ Features
58
58
 
59
- - 🔎 **Auto Instrumentation**: Works with 30+ LLM providers, vector databases, and GPUs with just one line of code.
59
+ - 🔎 **Auto Instrumentation**: Works with 40+ LLM providers, Agents, Vector databases, and GPUs with just one line of code.
60
60
  - 🔭 **OpenTelemetry-Native Observability SDKs**: Vendor-neutral SDKs that can send traces and metrics to your existing observability tool like Prometheus and Jaeger.
61
61
  - 💲 **Cost Tracking for Custom and Fine-Tuned Models**: Pass custom pricing files for accurate budgeting of custom and fine-tuned models.
62
62
  - 🚀 **Suppport for OpenLIT Features**: Includes suppprt for prompt management and secrets management features available in OpenLIT.
@@ -69,7 +69,7 @@ This project proudly follows and maintains the [Semantic Conventions](https://gi
69
69
  | [✅ Ollama](https://docs.openlit.io/latest/integrations/ollama) | [✅ Pinecone](https://docs.openlit.io/latest/integrations/pinecone) | [✅ LiteLLM](https://docs.openlit.io/latest/integrations/litellm) | [✅ AMD](https://docs.openlit.io/latest/integrations/amd-gpu) |
70
70
  | [✅ Anthropic](https://docs.openlit.io/latest/integrations/anthropic) | [✅ Qdrant](https://docs.openlit.io/latest/integrations/qdrant) | [✅ LlamaIndex](https://docs.openlit.io/latest/integrations/llama-index) | |
71
71
  | [✅ GPT4All](https://docs.openlit.io/latest/integrations/gpt4all) | [✅ Milvus](https://docs.openlit.io/latest/integrations/milvus) | [✅ Haystack](https://docs.openlit.io/latest/integrations/haystack) | |
72
- | [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | | [✅ EmbedChain](https://docs.openlit.io/latest/integrations/embedchain) | |
72
+ | [✅ Cohere](https://docs.openlit.io/latest/integrations/cohere) | [✅ AstraDB](https://docs.openlit.io/latest/integrations/astradb) | [✅ EmbedChain](https://docs.openlit.io/latest/integrations/embedchain) | |
73
73
  | [✅ Mistral](https://docs.openlit.io/latest/integrations/mistral) | | [✅ Guardrails](https://docs.openlit.io/latest/integrations/guardrails) | |
74
74
  | [✅ Azure OpenAI](https://docs.openlit.io/latest/integrations/azure-openai) | | [✅ CrewAI](https://docs.openlit.io/latest/integrations/crewai) | |
75
75
  | [✅ Azure AI Inference](https://docs.openlit.io/latest/integrations/azure-ai-inference) | | [✅ DSPy](https://docs.openlit.io/latest/integrations/dspy) | |
@@ -1,5 +1,5 @@
1
1
  openlit/__helpers.py,sha256=2OkGKOdsd9Hc011WxR70OqDlO6c4mZcu6McGuW1uAdA,6316
2
- openlit/__init__.py,sha256=F9WoSIEnxzZzZFGy1z---7gB7BlwMRcyph4lHdhgp-Q,20870
2
+ openlit/__init__.py,sha256=aFhA4yNRGE17CB1heL4GEWTZcPQZpJ1-7_yZel8cm6A,21000
3
3
  openlit/evals/__init__.py,sha256=nJe99nuLo1b5rf7pt9U9BCdSDedzbVi2Fj96cgl7msM,380
4
4
  openlit/evals/all.py,sha256=oWrue3PotE-rB5WePG3MRYSA-ro6WivkclSHjYlAqGs,7154
5
5
  openlit/evals/bias_detection.py,sha256=mCdsfK7x1vX7S3psC3g641IMlZ-7df3h-V6eiICj5N8,8154
@@ -17,6 +17,9 @@ openlit/instrumentation/ag2/ag2.py,sha256=_ncg8RqUH-wXMYfaOYx2bcQOrOrDMVVm0EZAEk
17
17
  openlit/instrumentation/anthropic/__init__.py,sha256=oaU53BOPyfUKbEzYvLr1DPymDluurSnwo4Hernf2XdU,1955
18
18
  openlit/instrumentation/anthropic/anthropic.py,sha256=y7CEGhKOGHWt8G_5Phr4qPJTfPGRJIAr9Yk6nM3CcvM,16775
19
19
  openlit/instrumentation/anthropic/async_anthropic.py,sha256=Zz1KRKIG9wGn0quOoLvjORC-49IvHQpJ6GBdB-4PfCQ,16816
20
+ openlit/instrumentation/astra/__init__.py,sha256=G4alCOR6hXQvUQPDCS8lY1rj0Mz-KmrW5vVWk5loO78,8054
21
+ openlit/instrumentation/astra/astra.py,sha256=ddZuzwhsszQK1nsttJrQ01YKsvbOJ4I6HHNFAS2KdtY,12074
22
+ openlit/instrumentation/astra/async_astra.py,sha256=4l6HlQdCjPKZNFmKRGqEO0LMkSvwxLbg4BJ6x5RrSu4,12086
20
23
  openlit/instrumentation/azure_ai_inference/__init__.py,sha256=Xl_4hjQeXcA-NgkqwTbs1ejPKRRnQXsDErXfFIz0z7U,2699
21
24
  openlit/instrumentation/azure_ai_inference/async_azure_ai_inference.py,sha256=T3SLSJxwrjOaGGkedB6DT92SCHLWbaJu5YAzZzAeBsk,22748
22
25
  openlit/instrumentation/azure_ai_inference/azure_ai_inference.py,sha256=IzwDZ99h7HpOI-NnEkYqOIh2sAm-2aHi4BcTMoXNx1c,22694
@@ -95,8 +98,8 @@ openlit/instrumentation/vllm/__init__.py,sha256=OVWalQ1dXvip1DUsjUGaHX4J-2FrSp-T
95
98
  openlit/instrumentation/vllm/vllm.py,sha256=lDzM7F5pgxvh8nKL0dcKB4TD0Mc9wXOWeXOsOGN7Wd8,6527
96
99
  openlit/otel/metrics.py,sha256=y7SQDTyfLakMrz0V4DThN-WAeap7YZzyndeYGSP6nVg,4516
97
100
  openlit/otel/tracing.py,sha256=fG3vl-flSZ30whCi7rrG25PlkIhhr8PhnfJYCkZzCD0,3895
98
- openlit/semcov/__init__.py,sha256=asA0rhBek-BcovxS2EVz-pTsLpt0FE6aaR-7RaIqPaQ,9877
99
- openlit-1.32.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
100
- openlit-1.32.2.dist-info/METADATA,sha256=96ZqO5vl3oosge89lLRgOQqHUUM5-I-bVdJWcItGDcM,22396
101
- openlit-1.32.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
102
- openlit-1.32.2.dist-info/RECORD,,
101
+ openlit/semcov/__init__.py,sha256=knUQxtYMGrW3fwfx8uXGn0E17WLxVPTkWVNQWvY4w8g,10079
102
+ openlit-1.32.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
103
+ openlit-1.32.3.dist-info/METADATA,sha256=qrskMzUSxlj4SSzStMeKinTmB9dArpURwvS-s5NGJAY,22430
104
+ openlit-1.32.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
105
+ openlit-1.32.3.dist-info/RECORD,,