Bugs fixes so XEvent profiler isn't broken (#577)

* Fix a few issues with profiler method handlers

* Filter out profiler polling events

* Add a unit test for profiler events

* Add method comment headers
This commit is contained in:
Karl Burtram
2018-01-17 18:21:40 -08:00
committed by GitHub
parent 7b1a88f842
commit 0121531bf6
7 changed files with 110 additions and 12 deletions

View File

@@ -89,6 +89,42 @@ namespace Microsoft.SqlTools.ServiceLayer.Profiler
}
}
/// <summary>
/// Determine if an event was caused by the XEvent polling queries
/// </summary>
private bool IsProfilerEvent(ProfilerEvent currentEvent)
{
if (string.IsNullOrWhiteSpace(currentEvent.Name) || currentEvent.Values == null)
{
return false;
}
if ((currentEvent.Name.Equals("sql_batch_completed")
|| currentEvent.Name.Equals("sql_batch_starting"))
&& currentEvent.Values.ContainsKey("batch_text"))
{
return currentEvent.Values["batch_text"].Contains("SELECT target_data FROM sys.dm_xe_session_targets");
}
return false;
}
/// <summary>
/// Removed profiler polling events from event list
/// </summary>
public List<ProfilerEvent> FilterProfilerEvents(List<ProfilerEvent> events)
{
int idx = events.Count;
while (--idx >= 0)
{
if (IsProfilerEvent(events[idx]))
{
events.RemoveAt(idx);
}
}
return events;
}
/// <summary>
/// Filter the event list to not include previously seen events
/// </summary>