Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ namespace OpenTelemetry.Instrumentation.SqlClient.Implementation
internal class SqlEventSourceListener : EventListener
{
internal const string AdoNetEventSourceName = "Microsoft-AdoNet-SystemData";
internal const string MdsEventSourceName = "Microsoft.Data.SqlClient.EventSource";

internal const int BeginExecuteEventId = 1;
internal const int EndExecuteEventId = 2;

private readonly SqlClientInstrumentationOptions options;
private EventSource eventSource;
private EventSource adoNetEventSource;
private EventSource mdsEventSource;

public SqlEventSourceListener(SqlClientInstrumentationOptions options = null)
{
Expand All @@ -43,9 +46,14 @@ public SqlEventSourceListener(SqlClientInstrumentationOptions options = null)

public override void Dispose()
{
if (this.eventSource != null)
if (this.adoNetEventSource != null)
{
this.DisableEvents(this.adoNetEventSource);
}

if (this.mdsEventSource != null)
{
this.DisableEvents(this.eventSource);
this.DisableEvents(this.mdsEventSource);
}

base.Dispose();
Expand All @@ -55,7 +63,13 @@ protected override void OnEventSourceCreated(EventSource eventSource)
{
if (eventSource?.Name.StartsWith(AdoNetEventSourceName, StringComparison.Ordinal) == true)
{
this.eventSource = eventSource;
this.adoNetEventSource = eventSource;
this.EnableEvents(eventSource, EventLevel.Informational, (EventKeywords)1);
}

if (eventSource?.Name.StartsWith(MdsEventSourceName, StringComparison.Ordinal) == true)
Comment thread
mbakalov marked this conversation as resolved.
Outdated
{
this.mdsEventSource = eventSource;
this.EnableEvents(eventSource, EventLevel.Informational, (EventKeywords)1);
}

Expand Down