Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to Microsoft.Data.Sqlclient 2.0+ events as well as those from … #2034

Merged
merged 8 commits into from
Nov 26, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ internal class FrameworkSqlEventListener : EventListener
/// </summary>
private const string AdoNetEventSourceName = "Microsoft-AdoNet-SystemData";

/// <summary>
/// The Microsoft.Data.SqlClient EventSource name for SQL.
/// </summary>
private const string MdsEventSourceName = "Microsoft.Data.SqlClient.EventSource";

/// <summary>
/// BeginExecute Event ID.
/// </summary>
Expand Down Expand Up @@ -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);
}

Expand Down