File tree Expand file tree Collapse file tree 1 file changed +25
-9
lines changed
sqlserver/datadog_checks/sqlserver/xe_collection Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -234,17 +234,33 @@ def _query_ring_buffer(self):
234
234
if self ._is_azure_sql_database :
235
235
level = "database_"
236
236
237
- # Get raw XML data without server-side parsing
238
- query = f"""
239
- SELECT CAST(t.target_data AS XML) AS target_xml
240
- FROM sys.dm_xe_{ level } sessions s
241
- JOIN sys.dm_xe_{ level } session_targets t
242
- ON s.address = t.event_session_address
243
- WHERE s.name = ?
244
- AND t.target_name = 'ring_buffer'
245
- """
237
+ # Determine if we need to use CONVERT based on connector type
238
+ use_convert = False
239
+ if self ._check .connection .connector == "adodbapi" :
240
+ use_convert = True
241
+ self ._log .debug ("Using CONVERT syntax for Windows/adodbapi compatibility" )
246
242
247
243
try :
244
+ # Choose the appropriate query based on connector type
245
+ if use_convert :
246
+ query = f"""
247
+ SELECT CONVERT(NVARCHAR(MAX), t.target_data) AS target_xml
248
+ FROM sys.dm_xe_{ level } sessions s
249
+ JOIN sys.dm_xe_{ level } session_targets t
250
+ ON s.address = t.event_session_address
251
+ WHERE s.name = ?
252
+ AND t.target_name = 'ring_buffer'
253
+ """
254
+ else :
255
+ query = f"""
256
+ SELECT CAST(t.target_data AS XML) AS target_xml
257
+ FROM sys.dm_xe_{ level } sessions s
258
+ JOIN sys.dm_xe_{ level } session_targets t
259
+ ON s.address = t.event_session_address
260
+ WHERE s.name = ?
261
+ AND t.target_name = 'ring_buffer'
262
+ """
263
+
248
264
cursor .execute (query , (self .session_name ,))
249
265
row = cursor .fetchone ()
250
266
if row and row [0 ]:
You can’t perform that action at this time.
0 commit comments