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

@@ -0,0 +1,78 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Collections.Generic;
namespace Microsoft.SqlTools.ServiceLayer.Profiler.Contracts
{
/// <summary>
/// Class that contains data for a single profile event
/// </summary>
public class ProfilerEvent
{
/// <summary>
/// Initialize a new ProfilerEvent with required parameters
/// </summary>
public ProfilerEvent(string name, string timestamp)
{
this.Name = name;
this.Timestamp = timestamp;
this.Values = new Dictionary<string, string>();
}
/// <summary>
/// Profiler event name
/// </summary>
public string Name { get; private set; }
/// <summary>
/// Profiler event timestamp
/// </summary>
public string Timestamp { get; private set; }
/// <summary>
/// Profiler event values collection
/// </summary>
public Dictionary<string, string> Values { get; private set; }
/// <summary>
/// Equals method
/// </summary>
public bool Equals(ProfilerEvent p)
{
// if parameter is null return false:
if ((object)p == null)
{
return false;
}
return this.Name == p.Name
&& this.Timestamp == p.Timestamp
&& this.Values.Count == p.Values.Count;
}
/// <summary>
/// GetHashCode method
/// </summary>
public override int GetHashCode()
{
int hashCode = this.GetType().ToString().GetHashCode();
if (this.Name != null)
{
hashCode ^= this.Name.GetHashCode();
}
if (this.Timestamp != null)
{
hashCode ^= this.Timestamp.GetHashCode();
}
hashCode ^= this.Values.Count.GetHashCode();
return hashCode;
}
}
}

View File

@@ -0,0 +1,27 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Collections.Generic;
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Profiler.Contracts
{
public class ProfilerEventsAvailableParams
{
public string SessionId { get; set; }
public List<ProfilerEvent> Events { get; set; }
}
public class ProfilerEventsAvailableNotification
{
public static readonly
EventType<ProfilerEventsAvailableParams> Type =
EventType<ProfilerEventsAvailableParams>.Create("profiler/eventsavailable");
}
}

View File

@@ -0,0 +1,55 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Profiler.Contracts
{
/// <summary>
/// Start Profiling request parameters
/// </summary>
public class StartProfilingParams : GeneralRequestDetails
{
public string OwnerUri { get; set; }
public string TemplateName
{
get
{
return GetOptionValue<string>("templateName");
}
set
{
SetOptionValue("templateName", value);
}
}
}
public class StartProfilingResult
{
/// <summary>
/// Session ID that was started
/// </summary>
public string SessionId { get; set; }
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary>
/// Start Profile request type
/// </summary>
public class StartProfilingRequest
{
/// <summary>
/// Request definition
/// </summary>
public static readonly
RequestType<StartProfilingParams, StartProfilingResult> Type =
RequestType<StartProfilingParams, StartProfilingResult>.Create("profiler/start");
}
}

View File

@@ -0,0 +1,38 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Profiler.Contracts
{
/// <summary>
/// Stop Profiling request parameters
/// </summary>
public class StopProfilingParams
{
public string SessionId { get; set; }
}
public class StopProfilingResult
{
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary>
/// Start Profile request type
/// </summary>
public class StopProfilingRequest
{
/// <summary>
/// Request definition
/// </summary>
public static readonly
RequestType<StopProfilingParams, StopProfilingResult> Type =
RequestType<StopProfilingParams, StopProfilingResult>.Create("profiler/stop");
}
}