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

Fix metrics size regression #106415

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -7,6 +7,9 @@
<method signature="System.Boolean IsEnabled(System.Diagnostics.Tracing.EventLevel,System.Diagnostics.Tracing.EventKeywords)" body="stub" value="false" />
<method signature="System.Boolean IsEnabled(System.Diagnostics.Tracing.EventLevel,System.Diagnostics.Tracing.EventKeywords,System.Diagnostics.Tracing.EventChannel)" body="stub" value="false" />
</type>
<type fullname="System.Diagnostics.Tracing.EventSource" feature="System.Diagnostics.Metrics.Meter.IsSupported" featurevalue="false">
<method signature="System.Boolean get_IsMeterSupported()" body="stub" value="false" />
</type>
<type fullname="System.Diagnostics.StackTrace" feature="System.Diagnostics.StackTrace.IsSupported" featurevalue="false">
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" />
</type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ public partial class EventSource : IDisposable
private static bool InitializeIsSupported() =>
AppContext.TryGetSwitch("System.Diagnostics.Tracing.EventSource.IsSupported", out bool isSupported) ? isSupported : true;

internal static bool IsMeterSupported { get; } = InitializeIsMeterSupported();

private static bool InitializeIsMeterSupported() =>
AppContext.TryGetSwitch("System.Diagnostics.Metrics.Meter.IsSupported", out bool isSupported) ? isSupported : true;

#if FEATURE_EVENTSOURCE_XPLAT
#pragma warning disable CA1823 // field is used to keep listener alive
private static readonly EventListener? persistent_Xplat_Listener = IsSupported ? XplatEventLogger.InitializePersistentListener() : null;
Expand Down Expand Up @@ -3831,7 +3836,7 @@ internal static void InitializeDefaultEventSources()
// Functionally we could preregister NativeRuntimeEventSource and RuntimeEventSource as well, but it may not provide
// much benefit. The main benefit for MetricsEventSource is that the app may never use it and it defers
// pulling the System.Diagnostics.DiagnosticSource assembly into the process until it is needed.
if (AppContext.TryGetSwitch("System.Diagnostics.Metrics.Meter.IsSupported", out bool isSupported) ? isSupported : true)
if (IsMeterSupported)
{
const string name = "System.Diagnostics.Metrics";
Guid id = new Guid("20752bc4-c151-50f5-f27b-df92d8af5a61");
Expand Down
Loading