Skip to content
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 @@ -4,7 +4,7 @@

### Features Added

* Add ability to specify EnableStandardMetrics and EnablePerfCounters
* Add ability to specify EnableStandardMetrics and EnablePerformanceCounters
([#56438](https://github.com/Azure/azure-sdk-for-net/pull/56438))

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public AzureMonitorOptions() { }
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLiveMetrics { get { throw null; } set { } }
public bool EnablePerfCounters { get { throw null; } set { } }
public bool EnablePerformanceCounters { get { throw null; } set { } }
public bool EnableStandardMetrics { get { throw null; } set { } }
public bool EnableTraceBasedLogsSampler { get { throw null; } set { } }
public float SamplingRatio { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public AzureMonitorOptions() { }
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLiveMetrics { get { throw null; } set { } }
public bool EnablePerfCounters { get { throw null; } set { } }
public bool EnablePerformanceCounters { get { throw null; } set { } }
public bool EnableStandardMetrics { get { throw null; } set { } }
public bool EnableTraceBasedLogsSampler { get { throw null; } set { } }
public float SamplingRatio { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public AzureMonitorOptions() { }
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLiveMetrics { get { throw null; } set { } }
public bool EnablePerfCounters { get { throw null; } set { } }
public bool EnablePerformanceCounters { get { throw null; } set { } }
public bool EnableStandardMetrics { get { throw null; } set { } }
public bool EnableTraceBasedLogsSampler { get { throw null; } set { } }
public float SamplingRatio { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class AzureMonitorOptions : ClientOptions
/// Gets or sets a value indicating whether performance counters should be collected.
/// Default is true.
/// </summary>
public bool EnablePerfCounters { get; set; } = true;
public bool EnablePerformanceCounters { get; set; } = true;
Comment thread
harsimar marked this conversation as resolved.

/// <summary>
/// Enables or disables filtering logs based on trace sampling decisions.
Expand Down Expand Up @@ -108,7 +108,7 @@ internal void SetValueToExporterOptions(AzureMonitorExporterOptions exporterOpti
exporterOptions.StorageDirectory = StorageDirectory;
exporterOptions.EnableLiveMetrics = EnableLiveMetrics;
exporterOptions.EnableStandardMetrics = EnableStandardMetrics;
exporterOptions.EnablePerfCounters = EnablePerfCounters;
exporterOptions.EnablePerformanceCounters = EnablePerformanceCounters;
exporterOptions.EnableTraceBasedLogsSampler = EnableTraceBasedLogsSampler;
if (Transport != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,36 +270,36 @@ public void UseAzureMonitor_EnableStandardMetrics_PropagatesCorrectly()
}

[Fact]
public void AzureMonitorOptions_EnablePerfCounters_DefaultValue_IsTrue()
public void AzureMonitorOptions_EnablePerformanceCounters_DefaultValue_IsTrue()
{
// Arrange & Act
var options = new AzureMonitorOptions();

// Assert
Assert.True(options.EnablePerfCounters);
Assert.True(options.EnablePerformanceCounters);
}

[Fact]
public void AzureMonitorOptions_EnablePerfCounters_CanBeDisabled()
public void AzureMonitorOptions_EnablePerformanceCounters_CanBeDisabled()
{
// Arrange & Act
var options = new AzureMonitorOptions
{
EnablePerfCounters = false
EnablePerformanceCounters = false
};

// Assert
Assert.False(options.EnablePerfCounters);
Assert.False(options.EnablePerformanceCounters);
}

[Fact]
public void AzureMonitorOptions_SetValueToExporterOptions_CopiesEnablePerfCounters()
public void AzureMonitorOptions_SetValueToExporterOptions_CopiesEnablePerformanceCounters()
{
// Arrange
var azureMonitorOptions = new AzureMonitorOptions
{
ConnectionString = TestConnectionString,
EnablePerfCounters = false
EnablePerformanceCounters = false
};

var exporterOptions = new AzureMonitorExporterOptions();
Expand All @@ -308,12 +308,12 @@ public void AzureMonitorOptions_SetValueToExporterOptions_CopiesEnablePerfCounte
azureMonitorOptions.SetValueToExporterOptions(exporterOptions);

// Assert
Assert.False(exporterOptions.EnablePerfCounters);
Assert.False(exporterOptions.EnablePerformanceCounters);
Assert.Equal(TestConnectionString, exporterOptions.ConnectionString);
}

[Fact]
public void UseAzureMonitor_DefaultEnablePerfCounters()
public void UseAzureMonitor_DefaultEnablePerformanceCounters()
{
// Arrange
var serviceCollection = new ServiceCollection();
Expand All @@ -332,16 +332,16 @@ public void UseAzureMonitor_DefaultEnablePerfCounters()
var azureMonitorOptions = serviceProvider.GetRequiredService<IOptionsMonitor<AzureMonitorOptions>>()
.Get(Options.DefaultName);

Assert.True(azureMonitorOptions.EnablePerfCounters);
Assert.True(azureMonitorOptions.EnablePerformanceCounters);

var exporterOptions = serviceProvider.GetRequiredService<IOptionsMonitor<AzureMonitorExporterOptions>>()
.Get(Options.DefaultName);

Assert.True(exporterOptions.EnablePerfCounters);
Assert.True(exporterOptions.EnablePerformanceCounters);
}

[Fact]
public void UseAzureMonitor_CanDisablePerfCounters()
public void UseAzureMonitor_CanDisablePerformanceCounters()
{
// Arrange
var serviceCollection = new ServiceCollection();
Expand All @@ -351,7 +351,7 @@ public void UseAzureMonitor_CanDisablePerfCounters()
.UseAzureMonitor(options =>
{
options.ConnectionString = TestConnectionString;
options.EnablePerfCounters = false;
options.EnablePerformanceCounters = false;
options.DisableOfflineStorage = true;
});

Expand All @@ -361,16 +361,16 @@ public void UseAzureMonitor_CanDisablePerfCounters()
var azureMonitorOptions = serviceProvider.GetRequiredService<IOptionsMonitor<AzureMonitorOptions>>()
.Get(Options.DefaultName);

Assert.False(azureMonitorOptions.EnablePerfCounters);
Assert.False(azureMonitorOptions.EnablePerformanceCounters);

var exporterOptions = serviceProvider.GetRequiredService<IOptionsMonitor<AzureMonitorExporterOptions>>()
.Get(Options.DefaultName);

Assert.False(exporterOptions.EnablePerfCounters);
Assert.False(exporterOptions.EnablePerformanceCounters);
}

[Fact]
public void UseAzureMonitor_EnablePerfCounters_PropagatesCorrectly()
public void UseAzureMonitor_EnablePerformanceCounters_PropagatesCorrectly()
{
// Arrange
var serviceCollection = new ServiceCollection();
Expand All @@ -380,7 +380,7 @@ public void UseAzureMonitor_EnablePerfCounters_PropagatesCorrectly()
.UseAzureMonitor(options =>
{
options.ConnectionString = TestConnectionString;
options.EnablePerfCounters = true;
options.EnablePerformanceCounters = true;
options.DisableOfflineStorage = true;
});

Expand All @@ -393,8 +393,8 @@ public void UseAzureMonitor_EnablePerfCounters_PropagatesCorrectly()
var exporterOptions = serviceProvider.GetRequiredService<IOptionsMonitor<AzureMonitorExporterOptions>>()
.Get(Options.DefaultName);

Assert.Equal(azureMonitorOptions.EnablePerfCounters, exporterOptions.EnablePerfCounters);
Assert.True(exporterOptions.EnablePerfCounters);
Assert.Equal(azureMonitorOptions.EnablePerformanceCounters, exporterOptions.EnablePerformanceCounters);
Assert.True(exporterOptions.EnablePerformanceCounters);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
([#57549](https://github.com/Azure/azure-sdk-for-net/pull/57549))
* Made `AzureMonitorLogExporter`, `AzureMonitorMetricExporter`, and `AzureMonitorTraceExporter` public for direct use when configuring OpenTelemetry.
([#56344](https://github.com/Azure/azure-sdk-for-net/pull/56344))
* Made options `EnablePerfCounters` and `EnableStandardMetrics` public in `AzureMonitorExporterOptions`.
* Made options `EnablePerformanceCounters` and `EnableStandardMetrics` public in `AzureMonitorExporterOptions`.
([#56344](https://github.com/Azure/azure-sdk-for-net/pull/56344))
Comment thread
harsimar marked this conversation as resolved.

## 1.6.0 (2026-01-28)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public AzureMonitorExporterOptions(Azure.Monitor.OpenTelemetry.Exporter.AzureMon
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLiveMetrics { get { throw null; } set { } }
public bool EnablePerfCounters { get { throw null; } set { } }
public bool EnablePerformanceCounters { get { throw null; } set { } }
public bool EnableStandardMetrics { get { throw null; } set { } }
public bool EnableTraceBasedLogsSampler { get { throw null; } set { } }
public float SamplingRatio { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public AzureMonitorExporterOptions(Azure.Monitor.OpenTelemetry.Exporter.AzureMon
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLiveMetrics { get { throw null; } set { } }
public bool EnablePerfCounters { get { throw null; } set { } }
public bool EnablePerformanceCounters { get { throw null; } set { } }
public bool EnableStandardMetrics { get { throw null; } set { } }
public bool EnableTraceBasedLogsSampler { get { throw null; } set { } }
public float SamplingRatio { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public AzureMonitorExporterOptions(Azure.Monitor.OpenTelemetry.Exporter.AzureMon
public Azure.Core.TokenCredential Credential { get { throw null; } set { } }
public bool DisableOfflineStorage { get { throw null; } set { } }
public bool EnableLiveMetrics { get { throw null; } set { } }
public bool EnablePerfCounters { get { throw null; } set { } }
public bool EnablePerformanceCounters { get { throw null; } set { } }
public bool EnableStandardMetrics { get { throw null; } set { } }
public bool EnableTraceBasedLogsSampler { get { throw null; } set { } }
public float SamplingRatio { get { throw null; } set { } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public enum ServiceVersion
/// Gets or sets a value indicating whether performance counters should be collected.
/// Default is true.
/// </summary>
public bool EnablePerfCounters { get; set; } = true;
public bool EnablePerformanceCounters { get; set; } = true;

internal void SetValueToLiveMetricsOptions(AzureMonitorLiveMetricsOptions liveMetricsOptions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal sealed class StandardMetricsExtractionProcessor : BaseProcessor<Activit
private AzureMonitorResource? _resource;

private readonly bool _enableStandardMetrics;
private readonly bool _enablePerfCounters;
private readonly bool _enablePerformanceCounters;

internal readonly Lazy<MeterProvider?> _meterProvider;
private readonly Meter? _standardMetricMeter;
Expand Down Expand Up @@ -73,12 +73,12 @@ internal sealed class StandardMetricsExtractionProcessor : BaseProcessor<Activit
internal StandardMetricsExtractionProcessor(AzureMonitorMetricExporter metricExporter, AzureMonitorExporterOptions options)
{
_enableStandardMetrics = options.EnableStandardMetrics;
_enablePerfCounters = options.EnablePerfCounters;
_enablePerformanceCounters = options.EnablePerformanceCounters;

// Initialize Lazy<T> for thread-safe lazy initialization of MeterProvider
_meterProvider = new Lazy<MeterProvider?>(() =>
{
if (!_enableStandardMetrics && !_enablePerfCounters)
if (!_enableStandardMetrics && !_enablePerformanceCounters)
{
return null;
}
Expand All @@ -90,7 +90,7 @@ internal StandardMetricsExtractionProcessor(AzureMonitorMetricExporter metricExp
meterProviderBuilder.AddMeter(StandardMetricConstants.StandardMetricMeterName);
}

if (_enablePerfCounters)
if (_enablePerformanceCounters)
{
meterProviderBuilder.AddMeter(PerfCounterConstants.PerfCounterMeterName);
}
Expand All @@ -115,7 +115,7 @@ internal StandardMetricsExtractionProcessor(AzureMonitorMetricExporter metricExp
_dependencyDuration = _standardMetricMeter.CreateHistogram<double>(StandardMetricConstants.DependencyDurationInstrumentName);
}

if (_enablePerfCounters)
if (_enablePerformanceCounters)
{
_process = Process.GetCurrentProcess();
_perfCounterMeter = new Meter(PerfCounterConstants.PerfCounterMeterName);
Expand Down Expand Up @@ -157,7 +157,7 @@ public override void OnEnd(Activity activity)
}

// Increment request count for rate calculation
if (_enablePerfCounters)
if (_enablePerformanceCounters)
{
Interlocked.Increment(ref _requestCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ public void ValidatePerfCountersDisabled()
var traceTelemetryItems = new List<TelemetryItem>();
var metricTelemetryItems = new List<TelemetryItem>();

var options = new AzureMonitorExporterOptions { EnablePerfCounters = false };
var options = new AzureMonitorExporterOptions { EnablePerformanceCounters = false };
var standardMetricCustomProcessor = new StandardMetricsExtractionProcessor(new AzureMonitorMetricExporter(new MockTransmitter(metricTelemetryItems)), options);

using var tracerProvider = Sdk.CreateTracerProviderBuilder()
Expand Down Expand Up @@ -687,7 +687,7 @@ public void ValidateBothMetricsAndPerfCountersDisabled()
var options = new AzureMonitorExporterOptions
{
EnableStandardMetrics = false,
EnablePerfCounters = false
EnablePerformanceCounters = false
};
var standardMetricCustomProcessor = new StandardMetricsExtractionProcessor(new AzureMonitorMetricExporter(new MockTransmitter(metricTelemetryItems)), options);

Expand Down Expand Up @@ -724,7 +724,7 @@ public void ValidateBothMetricsAndPerfCountersDisabled()
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void ValidateEnablePropertiesConfiguration(bool enableStandardMetrics, bool enablePerfCounters)
public void ValidateEnablePropertiesConfiguration(bool enableStandardMetrics, bool enablePerformanceCounters)
{
var activitySource = new ActivitySource(nameof(StandardMetricTests.ValidateEnablePropertiesConfiguration));
var traceTelemetryItems = new List<TelemetryItem>();
Expand All @@ -733,7 +733,7 @@ public void ValidateEnablePropertiesConfiguration(bool enableStandardMetrics, bo
var options = new AzureMonitorExporterOptions
{
EnableStandardMetrics = enableStandardMetrics,
EnablePerfCounters = enablePerfCounters
EnablePerformanceCounters = enablePerformanceCounters
};
var standardMetricCustomProcessor = new StandardMetricsExtractionProcessor(new AzureMonitorMetricExporter(new MockTransmitter(metricTelemetryItems)), options);

Expand Down Expand Up @@ -785,7 +785,7 @@ public void ValidateEnablePropertiesConfiguration(bool enableStandardMetrics, bo
var requestRate = FindMetric(PerfCounterConstants.RequestRateMetricIdValue);
var privateBytes = FindMetric(PerfCounterConstants.ProcessPrivateBytesMetricIdValue);

if (enablePerfCounters)
if (enablePerformanceCounters)
{
// At least some perf counter metrics should be present
Assert.True(requestRate != null || privateBytes != null, "Expected at least one performance counter metric when enabled");
Expand Down
Loading