From 49f7bdd9310d7c86bdb52d2333e09c84b3ea6d77 Mon Sep 17 00:00:00 2001 From: Ulf Axelsson Date: Tue, 8 Sep 2020 08:23:28 +0200 Subject: [PATCH] Listen to Microsoft.Data.Sqlclient 2.0+ events as well as those from System.Data(.SqlClient). --- .../Implementation/FrameworkSqlEventListener.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/WEB/Src/DependencyCollector/DependencyCollector/Implementation/FrameworkSqlEventListener.cs b/WEB/Src/DependencyCollector/DependencyCollector/Implementation/FrameworkSqlEventListener.cs index ed50cb64bf..6d6b077eed 100644 --- a/WEB/Src/DependencyCollector/DependencyCollector/Implementation/FrameworkSqlEventListener.cs +++ b/WEB/Src/DependencyCollector/DependencyCollector/Implementation/FrameworkSqlEventListener.cs @@ -23,6 +23,11 @@ internal class FrameworkSqlEventListener : EventListener /// private const string AdoNetEventSourceName = "Microsoft-AdoNet-SystemData"; + /// + /// The Microsoft.Data.SqlClient EventSource name for SQL. + /// + private const string MdsEventSourceName = "Microsoft.Data.SqlClient.EventSource"; + /// /// BeginExecute Event ID. /// @@ -63,6 +68,12 @@ protected override void OnEventSourceCreated(EventSource eventSource) DependencyCollectorEventSource.Log.RemoteDependencyModuleVerbose("SqlEventListener initialized for event source:" + AdoNetEventSourceName); } + if (eventSource != null && eventSource.Name == MdsEventSourceName) + { + this.EnableEvents(eventSource, EventLevel.Informational, (EventKeywords)1); + DependencyCollectorEventSource.Log.RemoteDependencyModuleVerbose("SqlEventListener initialized for event source:" + MdsEventSourceName); + } + base.OnEventSourceCreated(eventSource); }