-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/libraries/System.Diagnostics.DiagnosticSource/src/ILLink/ILLink.Substitutions.Shared.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<linker> | ||
<assembly fullname="System.Diagnostics.DiagnosticSource" feature="System.Diagnostics.Metrics.Meter.IsSupported" featurevalue="false"> | ||
<type fullname="System.Diagnostics.Metrics.Meter"> | ||
<method signature="System.Boolean get_IsSupported()" body="stub" value="false" /> | ||
</type> | ||
<type fullname="System.Diagnostics.Metrics.Instrument"> | ||
<method signature="System.Boolean get_Enabled()" body="stub" value="false" /> | ||
</type> | ||
</assembly> | ||
</linker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/libraries/System.Diagnostics.DiagnosticSource/tests/TestNotSupported.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.DotNet.RemoteExecutor; | ||
using System.Diagnostics.Metrics; | ||
using Xunit; | ||
|
||
namespace System.Diagnostics.Metrics.Tests | ||
{ | ||
public class MetricsNotSupportedTest | ||
{ | ||
/// <summary> | ||
/// Tests using Metrics when the System.Diagnostics.Metrics.Meter.IsSupported | ||
/// feature switch is set to disable all metrics operations. | ||
/// </summary> | ||
[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))] | ||
[InlineData(false)] | ||
[InlineData(true)] | ||
public void IsSupportedSwitch(bool value) | ||
{ | ||
RemoteInvokeOptions options = new RemoteInvokeOptions(); | ||
options.RuntimeConfigurationOptions.Add("System.Diagnostics.Metrics.Meter.IsSupported", value); | ||
|
||
RemoteExecutor.Invoke((val) => | ||
{ | ||
bool isSupported = bool.Parse(val); | ||
|
||
Meter meter = new Meter("IsSupportedTest"); | ||
Counter<long> counter = meter.CreateCounter<long>("counter"); | ||
bool instrumentsPublished = false; | ||
bool instrumentCompleted = false; | ||
long counterValue = 100; | ||
|
||
using (MeterListener listener = new MeterListener | ||
{ | ||
InstrumentPublished = (instruments, theListener) => instrumentsPublished = true, | ||
MeasurementsCompleted = (instruments, state) => instrumentCompleted = true | ||
}) | ||
{ | ||
listener.EnableMeasurementEvents(counter, null); | ||
listener.SetMeasurementEventCallback<long>((inst, measurement, tags, state) => counterValue = measurement); | ||
listener.Start(); | ||
|
||
Assert.Equal(isSupported, counter.Enabled); | ||
|
||
counter.Add(20); | ||
} | ||
meter.Dispose(); | ||
|
||
Assert.Equal(isSupported, instrumentsPublished); | ||
Assert.Equal(isSupported, instrumentCompleted); | ||
Assert.Equal(isSupported ? 20 : 100, counterValue); | ||
}, value.ToString(), options).Dispose(); | ||
} | ||
} | ||
} |