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

disable live metrics perf counters #41878

Merged
merged 4 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -62,7 +62,7 @@ public void SessionIdIsAddedToActivityTags()
Assert.Equal(_profiler.SessionId, activity.GetTagItem(ProfilingSessionTraceProcessor.TagName));
}

[Fact(Skip = "In Linux, it attempts to load performance counters. This will be enabled once we remove the dependency on them.")]
[Fact]
public void TraceProcessorIsAddedViaUseAzureMonitor()
{
// Configure DI services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

### Breaking Changes

* Disable Performance Counters to prevent runtime exceptions.
rajkumar-rangaraj marked this conversation as resolved.
Show resolved Hide resolved
CPU and Memory will no longer be displayed on the LiveMetrics chart.
([#41878](https://github.com/Azure/azure-sdk-for-net/pull/41878))

### Bugs Fixed

### Other Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Azure.Core" />
<PackageReference Include="OpenTelemetry" />
<PackageReference Include="OpenTelemetry.Exporter.Console" VersionOverride="1.6.0" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" VersionOverride="7.0.0" />
<!--<PackageReference Include="System.Diagnostics.PerformanceCounter" VersionOverride="7.0.0" />-->
</ItemGroup>

<!-- Shared sorce from Azure.Monitor.OpenTelemetry.Exporter -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ internal partial class Manager
internal readonly DoubleBuffer _documentBuffer = new();
internal static bool? s_isAzureWebApp = null;

private readonly PerformanceCounter _performanceCounter_ProcessorTime = new(categoryName: "Processor", counterName: "% Processor Time", instanceName: "_Total");
private readonly PerformanceCounter _performanceCounter_CommittedBytes = new(categoryName: "Memory", counterName: "Committed Bytes");
//private readonly PerformanceCounter _performanceCounter_ProcessorTime = new(categoryName: "Processor", counterName: "% Processor Time", instanceName: "_Total");
//private readonly PerformanceCounter _performanceCounter_CommittedBytes = new(categoryName: "Memory", counterName: "Committed Bytes");

public MonitoringDataPoint GetDataPoint()
{
Expand Down Expand Up @@ -91,31 +91,32 @@ public MonitoringDataPoint GetDataPoint()
dataPoint.Metrics.Add(metricPoint);
}

foreach (var metricPoint in CollectPerfCounters())
{
dataPoint.Metrics.Add(metricPoint);
}
// TODO: Reenable Perf Counters
//foreach (var metricPoint in CollectPerfCounters())
//{
// dataPoint.Metrics.Add(metricPoint);
//}

return dataPoint;
}

public IEnumerable<Models.MetricPoint> CollectPerfCounters()
{
// PERFORMANCE COUNTERS
yield return new Models.MetricPoint
{
Name = LiveMetricConstants.MetricId.MemoryCommittedBytesMetricIdValue,
Value = _performanceCounter_CommittedBytes.NextValue(),
Weight = 1
};
//public IEnumerable<Models.MetricPoint> CollectPerfCounters()
//{
// // PERFORMANCE COUNTERS
// yield return new Models.MetricPoint
// {
// Name = LiveMetricConstants.MetricId.MemoryCommittedBytesMetricIdValue,
// Value = _performanceCounter_CommittedBytes.NextValue(),
// Weight = 1
// };

yield return new Models.MetricPoint
{
Name = LiveMetricConstants.MetricId.ProcessorTimeMetricIdValue,
Value = _performanceCounter_ProcessorTime.NextValue(),
Weight = 1
};
}
// yield return new Models.MetricPoint
// {
// Name = LiveMetricConstants.MetricId.ProcessorTimeMetricIdValue,
// Value = _performanceCounter_ProcessorTime.NextValue(),
// Weight = 1
// };
//}

/// <summary>
/// Searches for the environment variable specific to Azure Web App.
Expand Down
Loading