0

I have one question. Can I work with extended events in Java code? Run sessions and analyze results. Is there a specific api or interface to do this?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

You are using XE trough T-SQL, like running/stopping sessions with ALTER EVENT SESSION:

ALTER EVENT SESSION test_session ON SERVER STATE = start;

And reading the events e.g. from Ring Buffer Target:

SELECT name, target_name, CAST(xet.target_data AS xml)  
FROM sys.dm_xe_session_targets AS xet  
JOIN sys.dm_xe_sessions AS xe  
   ON (xe.address = xet.event_session_address)  
WHERE xe.name = 'session_name'  

The result XML can be processed in the SQL Server, or you can process in in your Java code.

So the specific API you are looking for is Transact-SQL.

Andrey Nikolov
  • 12,967
  • 3
  • 20
  • 32