Files
sqltoolsservice/src/Microsoft.SqlTools.ServiceLayer/Profiler/XEventSession.cs
Madeline MacDonald f53e532225 Adding pausing functionality for the profiler (#634)
* Dropping profiler session on stop request

* Changes to IXEventSession to simplify dropping sessions

* Stop sessions instead of dropping, disable flaky tests

* Initial framework for profiler pause requests

* Restructuring profiler session monitoring

* Fixes to session monitor

* Testing for pause functionality

* Fixing comments from PR

* Changes to testing

* Commenting out flaky test

* Deleting leftover testing code
2018-06-13 17:55:01 -07:00

48 lines
1.2 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System.Linq;
using Microsoft.SqlServer.Management.XEvent;
using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.Profiler
{
/// <summary>
/// Class to access underlying XEvent session.
/// </summary>
public class XEventSession : IXEventSession
{
public Session Session { get; set; }
public int Id
{
get { return Session.ID; }
}
public void Start()
{
this.Session.Start();
}
public void Stop()
{
this.Session.Stop();
}
public string GetTargetXml()
{
if (this.Session == null)
{
return string.Empty;
}
// try to read events from the first target
Target defaultTarget = this.Session.Targets.FirstOrDefault();
return defaultTarget != null ? defaultTarget.GetTargetData() : string.Empty;
}
}
}