Unexpected error in .NET Core 3.1 when running "Collect metrics" sample from MS documentation
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 404
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 35
Description
### Description
The ["Collecting metrics" article](https://learn.microsoft.com/en-us/dotnet/core/diagnostics/metrics-collection) on MS Learn lists that all of its steps should be compatible with .NET Core 3.1 or later. However, I get an `Unsupported Command Exception` any time I target a .NET Core 3.1 app with `dotnet-counters`.
My version of the sample in .NET Core 3.1 is available [here](https://github.com/zsharp-gls/metric-instr)
When I run the .NET Core 3.1 version, this is the output when I try to use dotnet-counters:
```
PS C:\Users\zsharp> dotnet-counters monitor -n metric-instr HatCo.HatStore
Unhandled exception: Microsoft.Diagnostics.NETCore.Client.UnsupportedCommandException: GetProcessInfo failed - Command is not supported.
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.ValidateResponseMessage(IpcMessage responseMessage, String operationName, ValidateResponseOptions options) in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 750
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.GetProcessInfoFromResponse(IpcResponse response, String operationName) in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 707
at Microsoft.Diagnostics.NETCore.Client.DiagnosticsClient.GetProcessInfo() in /_/src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs:line 444
at Microsoft.Diagnostics.Tools.Counters.CounterMonitor.Monitor(CancellationToken ct, List`1 counter_list, String counters, IConsole console, Int32 processId, Int32 refreshInterval, String name, String diagnosticPort, Boolean resumeRuntime, Int32 maxHistograms, Int32 maxTimeSeries, TimeSpan duration, Boolean showDeltas) in /_/src/Tools/dotnet-counters/CounterMonitor.cs:line 213
at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__21_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__22_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<b__0>d.MoveNext()
```
I also created a branch targeting .NET 5.0, available [here](https://github.com/zsharp-gls/metric-instr/tree/net-5). When I run the same command against the .NET 5.0 version, it works just fine.
### Configuration
#### System info
- Windows 11, version 23H2 (OS Build 22631.3155)
```
PS C:\Users\zsharp> dotnet --info
.NET SDK:
Version: 8.0.102
Commit: 64f1bc458e
Workload version: 8.0.100-manifests.bc6351c6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.102\
.NET workloads installed:
Workload version: 8.0.100-manifests.bc6351c6
There are no installed workloads to display.
```
#### dotnet-counter version
```
PS C:\Users\zsharp> dotnet tool list -g
Package Id Version Commands
--------------------------------------------------------------
dotnet-counters 8.0.510501 dotnet-counters
```
### Other Info
I'm running this in a Windows PowerShell session with Administrator permissions. When I run without Administrator permissions, I get `Unhandled exception: System.UnauthorizedAccessException: Access to the path is denied.`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.