diagnostics icon indicating copy to clipboard operation
diagnostics copied to clipboard

dotnet-counters long value rendered format

Open WeihanLi opened this issue 1 year ago • 5 comments

The cms.sdk.offset value is a long number likes the unix milliseconds timestamp

The metrics value I recorded with the OpenTelemetry console exporter is expected

image

while the dotnet-counters tool seemed to change the value format when rendered like follows, is there some config or is it a bug?

image

It caused we could not tell whether it changed when there's small changes

WeihanLi avatar Nov 29 '23 08:11 WeihanLi

Found the format here

https://github.com/dotnet/diagnostics/blob/02f0dd5cb63cfa843351b874fb8acf73d87e6b9c/src/Tools/dotnet-counters/Exporters/ConsoleWriter.cs#L367

Is it possible to provide a config to show the raw value?

WeihanLi avatar Nov 29 '23 09:11 WeihanLi

cc @noahfalk who was planning on making some improvements to dotnet-counters output

tommcdon avatar Dec 04 '23 02:12 tommcdon

Sorry for the delay, I was on vacation all through December and returned to work recently. I just submitted a PR that adds an optional Deltas column (https://github.com/dotnet/diagnostics/pull/4455). It wasn't originally intended as a solution to this, but I think it still might do the job. Could you take a look and let me know what you think?

If the difference between successive measurements is < 10^9 then the delta would be shown in decimal form rather than scientific notation so you could see precise changes in value. I'd expect you'd see something like this:

Name                           Current Value    Last Delta
cms.sdk.offset                   1.7012e+12         312

If you do need to see the precise absolute value of the counter and not just its changes between consecutive measurements I'm open to more config switches that adjust the format.

noahfalk avatar Jan 09 '24 23:01 noahfalk

@noahfalk thanks very much for the help, think the delta would help for some cases indeed

while I may still want to know the exact value since we're monitoring the consume offset, and the consume offset is not increased by a fixed step, so a changed delta is not so helpful for the case, it would be better to know the exact value

WeihanLi avatar Jan 10 '24 03:01 WeihanLi

OK thanks for the feedback! I'll leave this issue open to track the request for adding a command-line option that prints the precise value in the 'Current Value' column rather than switching to scientific notation.

I can't make any promises when this might get implemented - if you are eager to have it a PR is welcome. I think my PR https://github.com/dotnet/diagnostics/pull/4455 gives a good idea on the general shape of a PR that adds a new command-line option, adds conditional formatting code in ConsoleWriter, and then adds some test cases to validate the new behavior. The command-line option could be something like --abbreviateLargeNumbers:false

noahfalk avatar Jan 12 '24 22:01 noahfalk