From 585dbd0e0ffbbecefc17f8bbe09a47418b05b285 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Fri, 9 Feb 2024 13:17:50 -0800 Subject: [PATCH 1/4] disable live metricsr perf counters --- .../ProfilingSessionTests.cs | 2 +- .../CHANGELOG.md | 4 ++ ...e.Monitor.OpenTelemetry.LiveMetrics.csproj | 2 +- .../src/Internals/Manager.Metrics.cs | 45 ++++++++++--------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/ProfilingSessionTests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/ProfilingSessionTests.cs index ecb6a2ba968d3..dfbb61c27ca8a 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/ProfilingSessionTests.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/tests/Azure.Monitor.OpenTelemetry.AspNetCore.Tests/ProfilingSessionTests.cs @@ -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 diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md index 8345bb0c1bccd..239e03445a295 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md @@ -6,6 +6,10 @@ ### Breaking Changes +* Disable Performance Counters to prevent runtime exceptions. + This will be reenabled in a future release. + ([]()) + ### Bugs Fixed ### Other Changes diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Azure.Monitor.OpenTelemetry.LiveMetrics.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Azure.Monitor.OpenTelemetry.LiveMetrics.csproj index c65ccaa41c91a..d71751a4b8693 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Azure.Monitor.OpenTelemetry.LiveMetrics.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Azure.Monitor.OpenTelemetry.LiveMetrics.csproj @@ -14,7 +14,7 @@ - + diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Internals/Manager.Metrics.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Internals/Manager.Metrics.cs index 43c29ea5b3047..a8a0445af6da9 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Internals/Manager.Metrics.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/src/Internals/Manager.Metrics.cs @@ -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() { @@ -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 CollectPerfCounters() - { - // PERFORMANCE COUNTERS - yield return new Models.MetricPoint - { - Name = LiveMetricConstants.MetricId.MemoryCommittedBytesMetricIdValue, - Value = _performanceCounter_CommittedBytes.NextValue(), - Weight = 1 - }; + //public IEnumerable 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 + // }; + //} /// /// Searches for the environment variable specific to Azure Web App. From 38c855ca9695d0039c5fa73929dd8601c38176e1 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Fri, 9 Feb 2024 13:18:43 -0800 Subject: [PATCH 2/4] changelog --- .../Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md index 239e03445a295..b525b4ccbb88b 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md @@ -8,7 +8,7 @@ * Disable Performance Counters to prevent runtime exceptions. This will be reenabled in a future release. - ([]()) + ([#41878](https://github.com/Azure/azure-sdk-for-net/pull/)) ### Bugs Fixed From dac6e5a1f8e9cb54b974209dd46aaa47bd8d58c9 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Fri, 9 Feb 2024 13:29:04 -0800 Subject: [PATCH 3/4] update changelog --- .../Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md index b525b4ccbb88b..ff5fc73f56353 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.LiveMetrics/CHANGELOG.md @@ -7,8 +7,8 @@ ### Breaking Changes * Disable Performance Counters to prevent runtime exceptions. - This will be reenabled in a future release. - ([#41878](https://github.com/Azure/azure-sdk-for-net/pull/)) + 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 From 64935b0ae678a493d8ea12a490da423fc1fb30f3 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Fri, 9 Feb 2024 13:43:02 -0800 Subject: [PATCH 4/4] change AspNetCore to use ProjectReference. --- .../src/Azure.Monitor.OpenTelemetry.AspNetCore.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/Azure.Monitor.OpenTelemetry.AspNetCore.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/Azure.Monitor.OpenTelemetry.AspNetCore.csproj index 87b57ce70aa70..033bfc58a1b71 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/Azure.Monitor.OpenTelemetry.AspNetCore.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.AspNetCore/src/Azure.Monitor.OpenTelemetry.AspNetCore.csproj @@ -24,11 +24,11 @@ - + - +