XEvent Profiler initial event handlers (#456)

* Bump SMO to 140.2.5 to pick-up private XEvent binaries

* Pick up SMO binaries from the build lab

* Add ProfilerService class placeholder

* Update SMO nuget package to include DB Scoped XEvents

* Stage changes

* Stage changes

* Update SMO to use RTM dependencies and remove separate SqlScript package

* Stage changes

* Iterate on profiler service

* Fix post-merge break in localization

* More refactoring

* Continue iterating on profiler

* Add test profiler listener

* Address a couple of the code review feedback

* Fix AppVeyor build break

* Use self-cleaning test file
This commit is contained in:
Karl Burtram
2017-09-12 14:08:50 -07:00
committed by GitHub
parent 2677efb6b8
commit 84ea045572
42 changed files with 1448 additions and 115 deletions

View File

@@ -12,6 +12,7 @@ using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Admin;
using Microsoft.SqlTools.ServiceLayer.Admin.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.FileBrowser;
@@ -77,7 +78,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName);
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName);
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
string backupPath = GetDefaultBackupFullPath(service, databaseName, helper.DataContainer, sqlConn);
@@ -102,7 +103,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName);
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName);
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
string backupPath = GetDefaultBackupFullPath(service, databaseName, helper.DataContainer, sqlConn);
BackupInfo backupInfo = CreateDefaultBackupInfo(databaseName,
@@ -135,7 +136,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName);
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName);
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
string backupPath = GetDefaultBackupFullPath(service, databaseName, helper.DataContainer, sqlConn);
string certificateName = CreateCertificate(testDb);
@@ -187,7 +188,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
SqlTestDb testDb = SqlTestDb.CreateNew(TestServerType.OnPrem, false, databaseName);
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName);
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
string backupPath = GetDefaultBackupFullPath(service, databaseName, helper.DataContainer, sqlConn);
string certificateName = CreateCertificate(testDb);
@@ -239,7 +240,7 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
// Initialize backup service
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName);
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
DisasterRecoveryService disasterRecoveryService = new DisasterRecoveryService();
BackupConfigInfo backupConfigInfo = disasterRecoveryService.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database);

View File

@@ -3,15 +3,16 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Data.SqlClient;
using System.IO;
using Microsoft.SqlTools.ServiceLayer.Admin;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using Microsoft.SqlTools.ServiceLayer.FileBrowser;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Xunit;
using System;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
@@ -25,7 +26,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
string backupPath = Path.Combine(GetDefaultBackupFolderPath(helper.DataContainer, sqlConn), "master.bak");
string message;
@@ -45,7 +46,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
string backupPath = GetDefaultBackupFolderPath(helper.DataContainer, sqlConn);
bool isFolder;

View File

@@ -606,7 +606,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
// Initialize backup service
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo(databaseName, queryTempFile.FilePath);
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database);
query = $"create table [test].[{tableNames[0]}] (c1 int)";
@@ -661,9 +661,9 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
// Initialize backup service
DatabaseTaskHelper helper = AdminService.CreateDatabaseTaskHelper(liveConnection.ConnectionInfo, databaseExists: true);
SqlConnection sqlConn = DisasterRecoveryService.GetSqlConnection(liveConnection.ConnectionInfo);
SqlConnection sqlConn = ConnectionService.OpenSqlConnection(liveConnection.ConnectionInfo);
// Get default backup path
// Get default backup pathS
BackupConfigInfo backupConfigInfo = DisasterRecoveryService.Instance.GetBackupConfigInfo(helper.DataContainer, sqlConn, sqlConn.Database);
string backupPath = Path.Combine(backupConfigInfo.DefaultBackupFolder, testDb.DatabaseName + ".bak");

View File

@@ -3,17 +3,18 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Xunit;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Threading.Tasks;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Metadata;
using System.Collections.Generic;
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
using System.Data.SqlClient;
using System;
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
using Moq;
using Microsoft.SqlTools.Hosting.Protocol;
using System.Threading.Tasks;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
{
@@ -71,7 +72,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
this.testTableName += new Random().Next(1000000, 9999999).ToString();
var result = GetLiveAutoCompleteTestObjects();
var sqlConn = MetadataService.OpenMetadataConnection(result.ConnectionInfo);
var sqlConn = ConnectionService.OpenSqlConnection(result.ConnectionInfo);
Assert.NotNull(sqlConn);
CreateTestTable(sqlConn);
@@ -101,7 +102,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Metadata
this.testTableName += new Random().Next(1000000, 9999999).ToString();
var result = GetLiveAutoCompleteTestObjects();
var sqlConn = MetadataService.OpenMetadataConnection(result.ConnectionInfo);
var sqlConn = ConnectionService.OpenSqlConnection(result.ConnectionInfo);
CreateTestTable(sqlConn);

View File

@@ -31,7 +31,7 @@
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.4" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.5" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />

View File

@@ -0,0 +1,90 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.XEvent;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Moq;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Profiler
{
public class ProfilerServiceTests
{
/// <summary>
/// Verify that a start profiling request starts a profiling session
/// </summary>
[Fact]
public async Task TestHandleStartAndStopProfilingRequests()
{
using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile())
{
var connectionResult = await LiveConnectionHelper.InitLiveConnectionInfoAsync("master", queryTempFile.FilePath);
ProfilerService profilerService = new ProfilerService();
// start a new session
var startParams = new StartProfilingParams();
startParams.OwnerUri = connectionResult.ConnectionInfo.OwnerUri;
startParams.TemplateName = "Standard";
string sessionId = null;
var startContext = new Mock<RequestContext<StartProfilingResult>>();
startContext.Setup(rc => rc.SendResult(It.IsAny<StartProfilingResult>()))
.Returns<StartProfilingResult>((result) =>
{
// capture the session id for sending the stop message
sessionId = result.SessionId;
return Task.FromResult(0);
});
await profilerService.HandleStartProfilingRequest(startParams, startContext.Object);
startContext.VerifyAll();
// wait a bit for the session monitoring to initialize
Thread.Sleep(TimeSpan.FromHours(1));
// stop the session
var stopParams = new StopProfilingParams()
{
SessionId = sessionId
};
var stopContext = new Mock<RequestContext<StopProfilingResult>>();
stopContext.Setup(rc => rc.SendResult(It.IsAny<StopProfilingResult>()))
.Returns(Task.FromResult(0));
await profilerService.HandleStopProfilingRequest(stopParams, stopContext.Object);
stopContext.VerifyAll();
}
}
/// <summary>
/// Verify the profiler service XEvent session factory
/// </summary>
[Fact]
public void TestCreateXEventSession()
{
var liveConnection = LiveConnectionHelper.InitLiveConnectionInfo("master");
ProfilerService profilerService = new ProfilerService();
IXEventSession xeSession = profilerService.CreateXEventSession(liveConnection.ConnectionInfo);
Assert.NotNull(xeSession);
Assert.NotNull(xeSession.GetTargetXml());
}
}
}

View File

@@ -12,7 +12,7 @@
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.4" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.5" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts/CreateTestDatabaseObjects.sql" />

View File

@@ -12,8 +12,7 @@
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.4" />
<PackageReference Include="Microsoft.SqlServer.Management.SqlScriptPublishModel" Version="140.2.4" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Microsoft.SqlTools.Hosting/Microsoft.SqlTools.Hosting.csproj" />

View File

@@ -13,7 +13,7 @@
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.4" />
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.2.5" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">

View File

@@ -0,0 +1,68 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.XEvent;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
{
/// <summary>
/// Unit tests for ProfilerService
/// </summary>
public class ProfilerServiceTests
{
/// <summary>
/// Test starting a profiling session and receiving event callback
/// </summary>
/// <returns></returns>
[Fact]
public async Task TestStartProfilingRequest()
{
string sessionId = null;
string testUri = "profiler_uri";
var requestContext = new Mock<RequestContext<StartProfilingResult>>();
requestContext.Setup(rc => rc.SendResult(It.IsAny<StartProfilingResult>()))
.Returns<StartProfilingResult>((result) =>
{
// capture the session id for sending the stop message
sessionId = result.SessionId;
return Task.FromResult(0);
});
var sessionListener = new TestSessionListener();
var profilerService = new ProfilerService();
profilerService.SessionMonitor.AddSessionListener(sessionListener);
profilerService.ConnectionServiceInstance = TestObjects.GetTestConnectionService();
ConnectionInfo connectionInfo = TestObjects.GetTestConnectionInfo();
profilerService.ConnectionServiceInstance.OwnerToConnectionMap.Add(testUri, connectionInfo);
profilerService.XEventSessionFactory = new TestXEventSessionFactory();
var requestParams = new StartProfilingParams();
requestParams.OwnerUri = testUri;
requestParams.TemplateName = "Standard";
await profilerService.HandleStartProfilingRequest(requestParams, requestContext.Object);
// wait a bit for profile sessions to be polled
Thread.Sleep(500);
requestContext.VerifyAll();
Assert.Equal(sessionListener.PreviousSessionId, sessionId);
Assert.Equal(sessionListener.PreviousEvents.Count, 1);
}
}
}

View File

@@ -0,0 +1,87 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Threading;
using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
{
/// <summary>
/// Tests for ProfilerSession class
/// </summary>
public class ProfilerSessionTests
{
/// <summary>
/// Test the FilterOldEvents method
/// </summary>
[Fact]
public void TestFilterOldEvents()
{
// create a profiler session and get some test events
var profilerSession = new ProfilerSession();
var profilerEvents = ProfilerTestObjects.TestProfilerEvents;
// filter old events shouldn't filter any new events
var newProfilerEvents = profilerSession.FilterOldEvents(profilerEvents);
Assert.Equal(profilerEvents.Count, newProfilerEvents.Count);
// filter should now filter all the events since they've been seen before
newProfilerEvents = profilerSession.FilterOldEvents(profilerEvents);
Assert.Equal(newProfilerEvents.Count, 0);
// add a new event
var newEvent = new ProfilerEvent("new event", "1/1/2017");
profilerEvents.Add(newEvent);
// verify we only have the new event when reprocessing the event list
newProfilerEvents = profilerSession.FilterOldEvents(profilerEvents);
Assert.Equal(newProfilerEvents.Count, 1);
Assert.True(newProfilerEvents[0].Equals(newEvent));
// process whole list again and verify nothing new is available
newProfilerEvents = profilerSession.FilterOldEvents(profilerEvents);
Assert.Equal(newProfilerEvents.Count, 0);
}
/// <summary>
/// Test the TryEnterPolling method
/// </summary>
[Fact]
public void TestTryEnterPolling()
{
DateTime startTime = DateTime.Now;
// create new profiler session
var profilerSession = new ProfilerSession();
// enter the polling block
Assert.True(profilerSession.TryEnterPolling());
Assert.True(profilerSession.IsPolling);
// verify we can't enter again
Assert.False(profilerSession.TryEnterPolling());
// set polling to false to exit polling block
profilerSession.IsPolling = false;
bool outsideDelay = DateTime.Now.Subtract(startTime) >= profilerSession.PollingDelay;
// verify we can only enter again if we're outside polling delay interval
Assert.Equal(profilerSession.TryEnterPolling(), outsideDelay);
// reset IsPolling in case the delay has elasped on slow machine or while debugging
profilerSession.IsPolling = false;
// wait for the polling delay to elapse
Thread.Sleep(profilerSession.PollingDelay);
// verify we can enter the polling block again
Assert.True(profilerSession.TryEnterPolling());
}
}
}

View File

@@ -0,0 +1,204 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlServer.Management.XEvent;
using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Microsoft.SqlTools.ServiceLayer.UnitTests.Utility;
using Moq;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Profiler
{
public static class ProfilerTestObjects
{
public static List<ProfilerEvent> TestProfilerEvents
{
get
{
return new List<ProfilerEvent>
{
new ProfilerEvent("event1", "1/1/2017"),
new ProfilerEvent("event2", "1/2/2017"),
new ProfilerEvent("event3", "1/3/2017")
};
}
}
}
public class TestSessionListener : IProfilerSessionListener
{
public string PreviousSessionId { get; set; }
public List<ProfilerEvent> PreviousEvents { get; set; }
public void EventsAvailable(string sessionId, List<ProfilerEvent> events)
{
this.PreviousSessionId = sessionId;
this.PreviousEvents = events;
}
}
public class TestXEventSession : IXEventSession
{
private string testXEventXml =
"<RingBufferTarget truncated=\"0\" processingTime=\"3\" totalEventsProcessed=\"1\" eventCount=\"1\" droppedCount=\"0\" memoryUsed=\"47996\">" +
" <event name=\"existing_connection\" package=\"sqlserver\" timestamp=\"2017-09-08T07:46:53.579Z\">" +
" <data name=\"session_id\">" +
" <type name=\"int16\" package=\"package0\"></type>" +
" <value>51</value>" +
" </data>" +
" <data name=\"is_dac\">" +
" <type name=\"boolean\" package=\"package0\"></type>" +
" <value>false</value>" +
" </data>" +
" <data name=\"database_id\">" +
" <type name=\"uint32\" package=\"package0\"></type>" +
" <value>1</value>" +
" </data>" +
" <data name=\"packet_size\">" +
" <type name=\"uint32\" package=\"package0\"></type>" +
" <value>4096</value>" +
" </data>" +
" <data name=\"transaction_count\">" +
" <type name=\"uint32\" package=\"package0\"></type>" +
" <value>0</value>" +
" </data>" +
" <data name=\"group_id\">" +
" <type name=\"uint32\" package=\"package0\"></type>" +
" <value>2</value>" +
" </data>" +
" <data name=\"duration\">" +
" <type name=\"uint64\" package=\"package0\"></type>" +
" <value>191053000</value>" +
" </data>" +
" <data name=\"client_pid\">" +
" <type name=\"uint32\" package=\"package0\"></type>" +
" <value>4680</value>" +
" </data>" +
" <data name=\"options\">" +
" <type name=\"binary_data\" package=\"package0\"></type>" +
" <value>2000002838f4010000000000</value>" +
" </data>" +
" <data name=\"options_text\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value>" +
" <![CDATA[-- network protocol: LPC" +
"set quoted_identifier on" +
"set arithabort off" +
"set numeric_roundabort off" +
"set ansi_warnings on" +
"set ansi_padding on" +
"set ansi_nulls on" +
"set concat_null_yields_null on" +
"set cursor_close_on_commit off" +
"set implicit_transactions off" +
"set language us_english" +
"set dateformat mdy" +
"set datefirst 7" +
"set transaction isolation level read committed" +
"]]>" +
" </value>" +
" </data>" +
" <data name=\"started_event_session_name\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[Profiler]]></value>" +
" </data>" +
" <data name=\"database_name\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[]]></value>" +
" </data>" +
" <data name=\"client_app_name\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[Microsoft SQL Server Management Studio]]></value>" +
" </data>" +
" <data name=\"client_hostname\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[KARLBURTRAMC189]]></value>" +
" </data>" +
" <data name=\"nt_domain\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[]]></value>" +
" </data>" +
" <data name=\"nt_user\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[]]></value>" +
" </data>" +
" <data name=\"session_nt_domain\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[]]></value>" +
" </data>" +
" <data name=\"session_nt_user\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[]]></value>" +
" </data>" +
" <data name=\"server_principal_name\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[sa]]></value>" +
" </data>" +
" <data name=\"server_principal_sid\">" +
" <type name=\"binary_data\" package=\"package0\"></type>" +
" <value>01</value>" +
" </data>" +
" <data name=\"session_server_principal_name\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[sa]]></value>" +
" </data>" +
" <data name=\"session_server_principal_sid\">" +
" <type name=\"binary_data\" package=\"package0\"></type>" +
" <value>01</value>" +
" </data>" +
" <action name=\"session_id\" package=\"sqlserver\">" +
" <type name=\"uint16\" package=\"package0\"></type>" +
" <value>56</value>" +
" </action>" +
" <action name=\"server_principal_name\" package=\"sqlserver\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[sa]]></value>" +
" </action>" +
" <action name=\"nt_username\" package=\"sqlserver\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[]]></value>" +
" </action>" +
" <action name=\"client_pid\" package=\"sqlserver\">" +
" <type name=\"uint32\" package=\"package0\"></type>" +
" <value>930958063</value>" +
" </action>" +
" <action name=\"client_app_name\" package=\"sqlserver\">" +
" <type name=\"unicode_string\" package=\"package0\"></type>" +
" <value><![CDATA[Core .Net SqlClient Data Provider]]></value>" +
" </action>" +
" <action name=\"attach_activity_id_xfer\" package=\"package0\">" +
" <type name=\"activity_id_xfer\" package=\"package0\"></type>" +
" <value>A2873402-C433-4D1F-94C4-9CA99749453E-0</value>" +
" </action>" +
" <action name=\"attach_activity_id\" package=\"package0\">" +
" <type name=\"activity_id\" package=\"package0\"></type>" +
" <value>770C3538-EC3F-4A27-86A9-31A2FC777DBC-1</value>" +
" </action>" +
" </event>" +
"</RingBufferTarget>";
public string GetTargetXml()
{
return testXEventXml;
}
}
public class TestXEventSessionFactory : IXEventSessionFactory
{
public IXEventSession CreateXEventSession(ConnectionInfo connInfo)
{
return new TestXEventSession();
}
}
}