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

Respect EventSource::IsSupported setting in more codepaths #51977

Merged
merged 6 commits into from
Jun 23, 2021
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 @@ -494,6 +494,9 @@ public static void SendCommand(EventSource eventSource, EventCommand command, ID
/// </summary>
public override string ToString()
{
if (!IsSupported)
return string.Empty;
stephentoub marked this conversation as resolved.
Show resolved Hide resolved

return SR.Format(SR.EventSource_ToString, Name, Guid);
}

Expand Down Expand Up @@ -667,8 +670,15 @@ public static void SetCurrentThreadActivityId(Guid activityId, out Guid oldActiv
/// the ETW provider name.
/// </summary>
protected EventSource()
: this(EventSourceSettings.EtwManifestEventFormat)
{
if (!IsSupported)
return;

#if FEATURE_PERFTRACING
m_eventHandleTable = new TraceLoggingEventHandleTable();
#endif
m_config = EventSourceSettings.EtwManifestEventFormat;
Initialize(null);
marek-safar marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
Expand Down Expand Up @@ -702,19 +712,23 @@ protected EventSource(EventSourceSettings settings) : this(settings, null) { }
/// <param name="traits">A collection of key-value strings (must be an even number).</param>
protected EventSource(EventSourceSettings settings, params string[]? traits)
{
if (IsSupported)
{
if (!IsSupported)
return;

#if FEATURE_PERFTRACING
m_eventHandleTable = new TraceLoggingEventHandleTable();
m_eventHandleTable = new TraceLoggingEventHandleTable();
#endif
m_config = ValidateSettings(settings);
m_config = ValidateSettings(settings);
Initialize(traits);
}

Type myType = this.GetType();
Guid eventSourceGuid = GetGuid(myType);
string eventSourceName = GetName(myType);
private void Initialize(string[]? traits)
{
Type myType = this.GetType();
Guid eventSourceGuid = GetGuid(myType);
string eventSourceName = GetName(myType);

Initialize(eventSourceGuid, eventSourceName, traits);
}
Initialize(eventSourceGuid, eventSourceName, traits);
}

#if FEATURE_PERFTRACING
Expand Down Expand Up @@ -1547,6 +1561,8 @@ internal EventSource(Guid eventSourceGuid, string eventSourceName, EventSourceSe
/// </summary>
private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, string[]? traits)
{
Debug.Assert(IsSupported);

try
{
m_traits = traits;
Expand Down