13
13
14
14
from ddtrace import config
15
15
from ddtrace .contrib .trace_utils import with_traced_module
16
+ from ddtrace .internal .utils .deprecations import DDTraceDeprecationWarning
16
17
from ddtrace .llmobs ._integrations import BedrockIntegration
17
18
from ddtrace .settings .config import Config
18
19
from ddtrace .vendor import wrapt
20
+ from ddtrace .vendor .debtcollector import deprecate
19
21
20
22
from ...constants import SPAN_KIND
21
23
from ...ext import SpanKind
77
79
)
78
80
79
81
80
- def get_version ():
82
+ def _get_version ():
81
83
# type: () -> str
82
84
return __version__
83
85
84
86
87
+ def get_version ():
88
+ deprecate (
89
+ "get_version is deprecated" ,
90
+ message = "get_version is deprecated" ,
91
+ removal_version = "3.0.0" ,
92
+ category = DDTraceDeprecationWarning ,
93
+ )
94
+ return _get_version ()
95
+
96
+
85
97
def patch ():
86
98
if getattr (botocore .client , "_datadog_patch" , False ):
87
99
return
88
100
botocore .client ._datadog_patch = True
89
101
90
102
botocore ._datadog_integration = BedrockIntegration (integration_config = config .botocore )
91
- wrapt .wrap_function_wrapper ("botocore.client" , "BaseClient._make_api_call" , patched_api_call (botocore ))
103
+ wrapt .wrap_function_wrapper ("botocore.client" , "BaseClient._make_api_call" , _patched_api_call (botocore ))
92
104
Pin ().onto (botocore .client .BaseClient )
93
- wrapt .wrap_function_wrapper ("botocore.parsers" , "ResponseParser.parse" , patched_lib_fn )
105
+ wrapt .wrap_function_wrapper ("botocore.parsers" , "ResponseParser.parse" , _patched_lib_fn )
94
106
Pin ().onto (botocore .parsers .ResponseParser )
95
107
_PATCHED_SUBMODULES .clear ()
96
108
@@ -103,7 +115,7 @@ def unpatch():
103
115
unwrap (botocore .client .BaseClient , "_make_api_call" )
104
116
105
117
106
- def patch_submodules (submodules ):
118
+ def _patch_submodules (submodules ):
107
119
# type: (Union[List[str], bool]) -> None
108
120
if isinstance (submodules , bool ) and submodules :
109
121
_PATCHED_SUBMODULES .clear ()
@@ -112,7 +124,17 @@ def patch_submodules(submodules):
112
124
_PATCHED_SUBMODULES .update (submodules )
113
125
114
126
115
- def patched_lib_fn (original_func , instance , args , kwargs ):
127
+ def patch_submodules (submodules ):
128
+ deprecate (
129
+ "patch_submodules is deprecated" ,
130
+ message = "patch_submodules is deprecated" ,
131
+ removal_version = "3.0.0" ,
132
+ category = DDTraceDeprecationWarning ,
133
+ )
134
+ return _patch_submodules (submodules )
135
+
136
+
137
+ def _patched_lib_fn (original_func , instance , args , kwargs ):
116
138
pin = Pin .get_from (instance )
117
139
if not pin or not pin .enabled () or not config .botocore ["instrument_internals" ]:
118
140
return original_func (* args , ** kwargs )
@@ -124,8 +146,18 @@ def patched_lib_fn(original_func, instance, args, kwargs):
124
146
return original_func (* args , ** kwargs )
125
147
126
148
149
+ def patched_lib_fn (original_func , instance , args , kwargs ):
150
+ deprecate (
151
+ "patched_lib_fn is deprecated" ,
152
+ message = "patched_lib_fn is deprecated" ,
153
+ removal_version = "3.0.0" ,
154
+ category = DDTraceDeprecationWarning ,
155
+ )
156
+ return _patched_lib_fn (original_func , instance , args , kwargs )
157
+
158
+
127
159
@with_traced_module
128
- def patched_api_call (botocore , pin , original_func , instance , args , kwargs ):
160
+ def _patched_api_call (botocore , pin , original_func , instance , args , kwargs ):
129
161
if not pin or not pin .enabled ():
130
162
return original_func (* args , ** kwargs )
131
163
@@ -153,7 +185,7 @@ def patched_api_call(botocore, pin, original_func, instance, args, kwargs):
153
185
if endpoint_name == "bedrock-runtime" and operation .startswith ("InvokeModel" ):
154
186
patching_fn = patched_bedrock_api_call
155
187
else :
156
- patching_fn = PATCHING_FUNCTIONS .get (endpoint_name , patched_api_call_fallback )
188
+ patching_fn = PATCHING_FUNCTIONS .get (endpoint_name , _patched_api_call_fallback )
157
189
158
190
return patching_fn (
159
191
original_func = original_func ,
@@ -164,7 +196,17 @@ def patched_api_call(botocore, pin, original_func, instance, args, kwargs):
164
196
)
165
197
166
198
167
- def prep_context_injection (ctx , endpoint_name , operation , trace_operation , params ):
199
+ def patched_api_call (botocore , pin , original_func , instance , args , kwargs ):
200
+ deprecate (
201
+ "patched_api_call is deprecated" ,
202
+ message = "patched_api_call is deprecated" ,
203
+ removal_version = "3.0.0" ,
204
+ category = DDTraceDeprecationWarning ,
205
+ )
206
+ return _patched_api_call (botocore , pin , original_func , instance , args , kwargs )
207
+
208
+
209
+ def _prep_context_injection (ctx , endpoint_name , operation , trace_operation , params ):
168
210
cloud_service = None
169
211
injection_function = None
170
212
schematization_function = schematize_cloud_messaging_operation
@@ -189,7 +231,17 @@ def prep_context_injection(ctx, endpoint_name, operation, trace_operation, param
189
231
)
190
232
191
233
192
- def patched_api_call_fallback (original_func , instance , args , kwargs , function_vars ):
234
+ def prep_context_injection (ctx , endpoint_name , operation , trace_operation , params ):
235
+ deprecate (
236
+ "prep_context_injection is deprecated" ,
237
+ message = "prep_context_injection is deprecated" ,
238
+ removal_version = "3.0.0" ,
239
+ category = DDTraceDeprecationWarning ,
240
+ )
241
+ return _prep_context_injection (ctx , endpoint_name , operation , trace_operation , params )
242
+
243
+
244
+ def _patched_api_call_fallback (original_func , instance , args , kwargs , function_vars ):
193
245
# default patched api call that is used generally for several services / operations
194
246
params = function_vars .get ("params" )
195
247
trace_operation = function_vars .get ("trace_operation" )
@@ -212,7 +264,7 @@ def patched_api_call_fallback(original_func, instance, args, kwargs, function_va
212
264
) as ctx , ctx .get_item ("instrumented_api_call" ):
213
265
core .dispatch ("botocore.patched_api_call.started" , [ctx ])
214
266
if args and config .botocore ["distributed_tracing" ]:
215
- prep_context_injection (ctx , endpoint_name , operation , trace_operation , params )
267
+ _prep_context_injection (ctx , endpoint_name , operation , trace_operation , params )
216
268
217
269
try :
218
270
result = original_func (* args , ** kwargs )
@@ -230,3 +282,13 @@ def patched_api_call_fallback(original_func, instance, args, kwargs, function_va
230
282
else :
231
283
core .dispatch ("botocore.patched_api_call.success" , [ctx , result ])
232
284
return result
285
+
286
+
287
+ def patched_api_call_fallback (original_func , instance , args , kwargs , function_vars ):
288
+ deprecate (
289
+ "patched_api_call_fallback is deprecated" ,
290
+ message = "patched_api_call_fallback is deprecated" ,
291
+ removal_version = "3.0.0" ,
292
+ category = DDTraceDeprecationWarning ,
293
+ )
294
+ return _patched_api_call_fallback (original_func , instance , args , kwargs , function_vars )
0 commit comments