openlit 1.33.13__py3-none-any.whl → 1.33.15__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/assemblyai/__init__.py +13 -13
- openlit/instrumentation/assemblyai/assemblyai.py +35 -28
- openlit/instrumentation/astra/__init__.py +82 -83
- openlit/instrumentation/astra/astra.py +26 -207
- openlit/instrumentation/astra/async_astra.py +27 -208
- openlit/instrumentation/astra/utils.py +102 -0
- openlit/instrumentation/azure_ai_inference/__init__.py +17 -18
- openlit/instrumentation/chroma/chroma.py +10 -10
- openlit/instrumentation/dynamiq/dynamiq.py +2 -2
- openlit/instrumentation/milvus/milvus.py +10 -10
- openlit/instrumentation/pinecone/pinecone.py +8 -8
- openlit/instrumentation/qdrant/async_qdrant.py +19 -19
- openlit/instrumentation/qdrant/qdrant.py +20 -20
- openlit/otel/metrics.py +18 -0
- openlit/semcov/__init__.py +26 -13
- {openlit-1.33.13.dist-info → openlit-1.33.15.dist-info}/METADATA +1 -1
- {openlit-1.33.13.dist-info → openlit-1.33.15.dist-info}/RECORD +19 -18
- {openlit-1.33.13.dist-info → openlit-1.33.15.dist-info}/LICENSE +0 -0
- {openlit-1.33.13.dist-info → openlit-1.33.15.dist-info}/WHEEL +0 -0
@@ -1,4 +1,3 @@
|
|
1
|
-
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
1
|
"""Initializer of Auto Instrumentation of AssemblyAI Functions"""
|
3
2
|
|
4
3
|
from typing import Collection
|
@@ -10,7 +9,7 @@ from openlit.instrumentation.assemblyai.assemblyai import (
|
|
10
9
|
transcribe
|
11
10
|
)
|
12
11
|
|
13
|
-
_instruments = (
|
12
|
+
_instruments = ('assemblyai >= 0.35.1',)
|
14
13
|
|
15
14
|
class AssemblyAIInstrumentor(BaseInstrumentor):
|
16
15
|
"""
|
@@ -21,21 +20,22 @@ class AssemblyAIInstrumentor(BaseInstrumentor):
|
|
21
20
|
return _instruments
|
22
21
|
|
23
22
|
def _instrument(self, **kwargs):
|
24
|
-
application_name = kwargs.get(
|
25
|
-
environment = kwargs.get(
|
26
|
-
tracer = kwargs.get(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
application_name = kwargs.get('application_name', 'default')
|
24
|
+
environment = kwargs.get('environment', 'default')
|
25
|
+
tracer = kwargs.get('tracer')
|
26
|
+
event_provider = kwargs.get('event_provider')
|
27
|
+
metrics = kwargs.get('metrics_dict')
|
28
|
+
pricing_info = kwargs.get('pricing_info', {})
|
29
|
+
capture_message_content = kwargs.get('capture_message_content', False)
|
30
|
+
disable_metrics = kwargs.get('disable_metrics')
|
31
|
+
version = importlib.metadata.version('assemblyai')
|
32
32
|
|
33
33
|
# sync transcribe
|
34
34
|
wrap_function_wrapper(
|
35
|
-
|
36
|
-
|
35
|
+
'assemblyai.transcriber',
|
36
|
+
'Transcriber.transcribe',
|
37
37
|
transcribe(version, environment, application_name,
|
38
|
-
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
38
|
+
tracer, event_provider, pricing_info, capture_message_content, metrics, disable_metrics),
|
39
39
|
)
|
40
40
|
|
41
41
|
def _uninstrument(self, **kwargs):
|
@@ -10,7 +10,8 @@ from openlit.__helpers import (
|
|
10
10
|
get_audio_model_cost,
|
11
11
|
handle_exception,
|
12
12
|
create_metrics_attributes,
|
13
|
-
set_server_address_and_port
|
13
|
+
set_server_address_and_port,
|
14
|
+
otel_event
|
14
15
|
)
|
15
16
|
from openlit.semcov import SemanticConvetion
|
16
17
|
|
@@ -18,38 +19,15 @@ from openlit.semcov import SemanticConvetion
|
|
18
19
|
logger = logging.getLogger(__name__)
|
19
20
|
|
20
21
|
def transcribe(version, environment, application_name,
|
21
|
-
tracer, pricing_info, capture_message_content, metrics, disable_metrics):
|
22
|
+
tracer, event_provider, pricing_info, capture_message_content, metrics, disable_metrics):
|
22
23
|
"""
|
23
|
-
Generates a telemetry wrapper for
|
24
|
-
|
25
|
-
Args:
|
26
|
-
gen_ai_endpoint: Endpoint identifier for logging and tracing.
|
27
|
-
version: Version of the monitoring package.
|
28
|
-
environment: Deployment environment (e.g., production, staging).
|
29
|
-
application_name: Name of the application using the Assembly AI API.
|
30
|
-
tracer: OpenTelemetry tracer for creating spans.
|
31
|
-
pricing_info: Information used for calculating the cost of generating speech audio.
|
32
|
-
capture_message_content: Flag indicating whether to trace the input text and generated audio.
|
33
|
-
|
34
|
-
Returns:
|
35
|
-
A function that wraps the speech audio creation method to add telemetry.
|
24
|
+
Generates a telemetry wrapper for GenAI function call
|
36
25
|
"""
|
37
26
|
|
27
|
+
|
38
28
|
def wrapper(wrapped, instance, args, kwargs):
|
39
29
|
"""
|
40
|
-
Wraps the
|
41
|
-
|
42
|
-
This collects metrics such as execution time, cost, and handles errors
|
43
|
-
gracefully, adding details to the trace for observability.
|
44
|
-
|
45
|
-
Args:
|
46
|
-
wrapped: The original 'generate' method to be wrapped.
|
47
|
-
instance: The instance of the class where the original method is defined.
|
48
|
-
args: Positional arguments for the 'generate' method.
|
49
|
-
kwargs: Keyword arguments for the 'generate' method.
|
50
|
-
|
51
|
-
Returns:
|
52
|
-
The response from the original 'transcribe' method.
|
30
|
+
Wraps the GenAI function call.
|
53
31
|
"""
|
54
32
|
|
55
33
|
server_address, server_port = set_server_address_and_port(instance, 'api.assemblyai.com', 443)
|
@@ -96,6 +74,7 @@ def transcribe(version, environment, application_name,
|
|
96
74
|
span.set_attribute(SemanticConvetion.GEN_AI_SDK_VERSION,
|
97
75
|
version)
|
98
76
|
|
77
|
+
# To be removed one the change to log events (from span events) is complete
|
99
78
|
if capture_message_content:
|
100
79
|
span.add_event(
|
101
80
|
name=SemanticConvetion.GEN_AI_CONTENT_PROMPT_EVENT,
|
@@ -110,6 +89,34 @@ def transcribe(version, environment, application_name,
|
|
110
89
|
},
|
111
90
|
)
|
112
91
|
|
92
|
+
input_event = otel_event(
|
93
|
+
name=SemanticConvetion.GEN_AI_USER_MESSAGE,
|
94
|
+
attributes={
|
95
|
+
SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI
|
96
|
+
},
|
97
|
+
body={
|
98
|
+
**({'content': response.audio_url} if capture_message_content else {}),
|
99
|
+
'role': 'user'
|
100
|
+
}
|
101
|
+
)
|
102
|
+
event_provider.emit(input_event)
|
103
|
+
|
104
|
+
output_event = otel_event(
|
105
|
+
name=SemanticConvetion.GEN_AI_CHOICE,
|
106
|
+
attributes={
|
107
|
+
SemanticConvetion.GEN_AI_SYSTEM: SemanticConvetion.GEN_AI_SYSTEM_ASSEMBLYAI
|
108
|
+
},
|
109
|
+
body={
|
110
|
+
'finish_reason': 'stop',
|
111
|
+
'index': 0,
|
112
|
+
'message': {
|
113
|
+
**({'content': response.text} if capture_message_content else {}),
|
114
|
+
'role': 'assistant'
|
115
|
+
}
|
116
|
+
}
|
117
|
+
)
|
118
|
+
event_provider.emit(output_event)
|
119
|
+
|
113
120
|
span.set_status(Status(StatusCode.OK))
|
114
121
|
|
115
122
|
if disable_metrics is False:
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
|
2
1
|
"""Initializer of Auto Instrumentation of AstraDB Functions"""
|
3
2
|
from typing import Collection
|
4
3
|
import importlib.metadata
|
@@ -8,7 +7,7 @@ from wrapt import wrap_function_wrapper
|
|
8
7
|
from openlit.instrumentation.astra.astra import general_wrap
|
9
8
|
# from openlit.instrumentation.astra.async_astra import asyc_general_wrap
|
10
9
|
|
11
|
-
_instruments = (
|
10
|
+
_instruments = ('astrapy >= 1.5.2',)
|
12
11
|
|
13
12
|
class AstraInstrumentor(BaseInstrumentor):
|
14
13
|
"""An instrumentor for AstraDB's client library."""
|
@@ -17,163 +16,163 @@ class AstraInstrumentor(BaseInstrumentor):
|
|
17
16
|
return _instruments
|
18
17
|
|
19
18
|
def _instrument(self, **kwargs):
|
20
|
-
application_name = kwargs.get(
|
21
|
-
environment = kwargs.get(
|
22
|
-
tracer = kwargs.get(
|
23
|
-
metrics = kwargs.get(
|
24
|
-
pricing_info = kwargs.get(
|
25
|
-
capture_message_content = kwargs.get(
|
26
|
-
disable_metrics = kwargs.get(
|
27
|
-
version = importlib.metadata.version(
|
19
|
+
application_name = kwargs.get('application_name')
|
20
|
+
environment = kwargs.get('environment')
|
21
|
+
tracer = kwargs.get('tracer')
|
22
|
+
metrics = kwargs.get('metrics_dict')
|
23
|
+
pricing_info = kwargs.get('pricing_info')
|
24
|
+
capture_message_content = kwargs.get('capture_message_content')
|
25
|
+
disable_metrics = kwargs.get('disable_metrics')
|
26
|
+
version = importlib.metadata.version('astrapy')
|
28
27
|
|
29
28
|
# Sync
|
30
29
|
wrap_function_wrapper(
|
31
|
-
|
32
|
-
|
33
|
-
general_wrap(
|
30
|
+
'astrapy.database',
|
31
|
+
'Database.create_collection',
|
32
|
+
general_wrap('astra.create_collection', version, environment, application_name,
|
34
33
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
35
34
|
)
|
36
35
|
wrap_function_wrapper(
|
37
|
-
|
38
|
-
|
39
|
-
general_wrap(
|
36
|
+
'astrapy.database',
|
37
|
+
'Database.drop_collection',
|
38
|
+
general_wrap('astra.drop_collection', version, environment, application_name,
|
40
39
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
41
40
|
)
|
42
41
|
wrap_function_wrapper(
|
43
|
-
|
44
|
-
|
45
|
-
general_wrap(
|
42
|
+
'astrapy.collection',
|
43
|
+
'Collection.insert_one',
|
44
|
+
general_wrap('astra.insert', version, environment, application_name,
|
46
45
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
47
46
|
)
|
48
47
|
wrap_function_wrapper(
|
49
|
-
|
50
|
-
|
51
|
-
general_wrap(
|
48
|
+
'astrapy.collection',
|
49
|
+
'Collection.insert_many',
|
50
|
+
general_wrap('astra.insert', version, environment, application_name,
|
52
51
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
53
52
|
)
|
54
53
|
wrap_function_wrapper(
|
55
|
-
|
56
|
-
|
57
|
-
general_wrap(
|
54
|
+
'astrapy.collection',
|
55
|
+
'Collection.update_one',
|
56
|
+
general_wrap('astra.update', version, environment, application_name,
|
58
57
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
59
58
|
)
|
60
59
|
wrap_function_wrapper(
|
61
|
-
|
62
|
-
|
63
|
-
general_wrap(
|
60
|
+
'astrapy.collection',
|
61
|
+
'Collection.update_many',
|
62
|
+
general_wrap('astra.update', version, environment, application_name,
|
64
63
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
65
64
|
)
|
66
65
|
wrap_function_wrapper(
|
67
|
-
|
68
|
-
|
69
|
-
general_wrap(
|
66
|
+
'astrapy.collection',
|
67
|
+
'Collection.find_one_and_update',
|
68
|
+
general_wrap('astra.find_one_and_update', version, environment, application_name,
|
70
69
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
71
70
|
)
|
72
71
|
wrap_function_wrapper(
|
73
|
-
|
74
|
-
|
75
|
-
general_wrap(
|
72
|
+
'astrapy.collection',
|
73
|
+
'Collection.find',
|
74
|
+
general_wrap('astra.find', version, environment, application_name,
|
76
75
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
77
76
|
)
|
78
77
|
wrap_function_wrapper(
|
79
|
-
|
80
|
-
|
81
|
-
general_wrap(
|
78
|
+
'astrapy.collection',
|
79
|
+
'Collection.replace_one',
|
80
|
+
general_wrap('astra.replace_one', version, environment, application_name,
|
82
81
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
83
82
|
)
|
84
83
|
wrap_function_wrapper(
|
85
|
-
|
86
|
-
|
87
|
-
general_wrap(
|
84
|
+
'astrapy.collection',
|
85
|
+
'Collection.find_one_and_delete',
|
86
|
+
general_wrap('astra.find_one_and_delete', version, environment, application_name,
|
88
87
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
89
88
|
)
|
90
89
|
wrap_function_wrapper(
|
91
|
-
|
92
|
-
|
93
|
-
general_wrap(
|
90
|
+
'astrapy.collection',
|
91
|
+
'Collection.delete_one',
|
92
|
+
general_wrap('astra.delete', version, environment, application_name,
|
94
93
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
95
94
|
)
|
96
95
|
wrap_function_wrapper(
|
97
|
-
|
98
|
-
|
99
|
-
general_wrap(
|
96
|
+
'astrapy.collection',
|
97
|
+
'Collection.delete_many',
|
98
|
+
general_wrap('astra.delete', version, environment, application_name,
|
100
99
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
101
100
|
)
|
102
101
|
|
103
102
|
# ASync
|
104
103
|
wrap_function_wrapper(
|
105
|
-
|
106
|
-
|
107
|
-
general_wrap(
|
104
|
+
'astrapy.database',
|
105
|
+
'AsyncDatabase.create_collection',
|
106
|
+
general_wrap('astra.create_collection', version, environment, application_name,
|
108
107
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
109
108
|
)
|
110
109
|
wrap_function_wrapper(
|
111
|
-
|
112
|
-
|
113
|
-
general_wrap(
|
110
|
+
'astrapy.database',
|
111
|
+
'AsyncDatabase.drop_collection',
|
112
|
+
general_wrap('astra.drop_collection', version, environment, application_name,
|
114
113
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
115
114
|
)
|
116
115
|
wrap_function_wrapper(
|
117
|
-
|
118
|
-
|
119
|
-
general_wrap(
|
116
|
+
'astrapy.collection',
|
117
|
+
'AsyncCollection.insert_one',
|
118
|
+
general_wrap('astra.insert_one', version, environment, application_name,
|
120
119
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
121
120
|
)
|
122
121
|
wrap_function_wrapper(
|
123
|
-
|
124
|
-
|
125
|
-
general_wrap(
|
122
|
+
'astrapy.collection',
|
123
|
+
'AsyncCollection.insert_many',
|
124
|
+
general_wrap('astra.insert_many', version, environment, application_name,
|
126
125
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
127
126
|
)
|
128
127
|
wrap_function_wrapper(
|
129
|
-
|
130
|
-
|
131
|
-
general_wrap(
|
128
|
+
'astrapy.collection',
|
129
|
+
'AsyncCollection.update_one',
|
130
|
+
general_wrap('astra.update_one', version, environment, application_name,
|
132
131
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
133
132
|
)
|
134
133
|
wrap_function_wrapper(
|
135
|
-
|
136
|
-
|
137
|
-
general_wrap(
|
134
|
+
'astrapy.collection',
|
135
|
+
'AsyncCollection.update_many',
|
136
|
+
general_wrap('astra.update_many', version, environment, application_name,
|
138
137
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
139
138
|
)
|
140
139
|
wrap_function_wrapper(
|
141
|
-
|
142
|
-
|
143
|
-
general_wrap(
|
140
|
+
'astrapy.collection',
|
141
|
+
'AsyncCollection.find_one_and_update',
|
142
|
+
general_wrap('astra.find_one_and_update', version, environment, application_name,
|
144
143
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
145
144
|
)
|
146
145
|
wrap_function_wrapper(
|
147
|
-
|
148
|
-
|
149
|
-
general_wrap(
|
146
|
+
'astrapy.collection',
|
147
|
+
'AsyncCollection.find',
|
148
|
+
general_wrap('astra.find', version, environment, application_name,
|
150
149
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
151
150
|
)
|
152
151
|
wrap_function_wrapper(
|
153
|
-
|
154
|
-
|
155
|
-
general_wrap(
|
152
|
+
'astrapy.collection',
|
153
|
+
'AsyncCollection.replace_one',
|
154
|
+
general_wrap('astra.replace_one', version, environment, application_name,
|
156
155
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
157
156
|
)
|
158
157
|
wrap_function_wrapper(
|
159
|
-
|
160
|
-
|
161
|
-
general_wrap(
|
158
|
+
'astrapy.collection',
|
159
|
+
'AsyncCollection.find_one_and_delete',
|
160
|
+
general_wrap('astra.find_one_and_delete', version, environment, application_name,
|
162
161
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
163
162
|
)
|
164
163
|
wrap_function_wrapper(
|
165
|
-
|
166
|
-
|
167
|
-
general_wrap(
|
164
|
+
'astrapy.collection',
|
165
|
+
'AsyncCollection.delete_one',
|
166
|
+
general_wrap('astra.delete_one', version, environment, application_name,
|
168
167
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
169
168
|
)
|
170
169
|
wrap_function_wrapper(
|
171
|
-
|
172
|
-
|
173
|
-
general_wrap(
|
170
|
+
'astrapy.collection',
|
171
|
+
'AsyncCollection.delete_many',
|
172
|
+
general_wrap('astra.delete_many', version, environment, application_name,
|
174
173
|
tracer, pricing_info, capture_message_content, metrics, disable_metrics),
|
175
174
|
)
|
176
175
|
|
177
|
-
@staticmethod
|
178
176
|
def _uninstrument(self, **kwargs):
|
177
|
+
# Proper uninstrumentation logic to revert patched methods
|
179
178
|
pass
|