When trying to run dotnet-counters collect, it appears that it's only wired to run in the foreground, waiting for a key press to terminate. Otherwise, I've been getting the following error:
Unhandled exception: System.InvalidOperationException: Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek.
at System.Console.get_KeyAvailable()
at Microsoft.Diagnostics.Tools.Counters.CounterMonitor.Start() in /_/src/Tools/dotnet-counters/CounterMonitor.cs:line 265
at Microsoft.Diagnostics.Tools.Counters.CounterMonitor.Collect(CancellationToken ct, List`1 counter_list, IConsole console, Int32 processId, Int32 refreshInterval, CountersExportFormat format, String output) in /_/src/Tools/dotnet-counters/CounterMonitor.cs:line 151
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.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseParseErrorReporting>b__22_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass8_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseSuggestDirective>b__7_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseParseDirective>b__6_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c.<<UseHelp>b__20_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass4_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c.<<RegisterWithDotnetSuggest>b__23_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.CommandLine.Invocation.InvocationExtensions.<>c__DisplayClass5_0.<<UseExceptionHandler>b__0>d.MoveNext()
Is there any way to circumvent this? If not, is there a reason why this tool wasn't written with the ability to be run in the background? We would love to be able to have this run while our application is running as monitoring over a longer refresh interval.
When trying to run
dotnet-counters collect, it appears that it's only wired to run in the foreground, waiting for a key press to terminate. Otherwise, I've been getting the following error:Is there any way to circumvent this? If not, is there a reason why this tool wasn't written with the ability to be run in the background? We would love to be able to have this run while our application is running as monitoring over a longer refresh interval.