Broken double value representation under .Net Core
See original GitHub issueHello! We use prometheus client under .Net Core with the default culture where decimal separator is comma (‘,’). And we get broken text representation of metrics (instead of dots, commas are used):
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 4,28125
Such representation can not be parsed by Prometheus Server.
It seems to be issue here: Prometheus.Client/src/Prometheus.Client/MetricsWriter/MetricsTextWriter.cs, line 264
(method Write(double value)
).
I assume that instead of value.TryFormat(buff, out var charsize);
it should be value.TryFormat(buff, out var charsize, CultureInfo.InvariantCulture);
like in the code branch below: Write(value.ToString(CultureInfo.InvariantCulture));
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
The double value that I defined to the variable is changing
I have a problem with conversation of double values. In the picture Project's framework is .NET6 and i tried on .NET5 and i...
Read more >Floating-Point Parsing and Formatting improvements in . ...
The fixes ensured that double. Parse/float. Parse would return the same result as the C#, VB, or F# compiler for the corresponding literal...
Read more >float handling differences between .NET Core and ...
Additionally, due to the underlying representation, not all values are "exactly" representable. float and double are represented using powers of ...
Read more >Double Struct (System)
It is intended to represent values that are extremely large (such as distances between planets or galaxies) or extremely small (such as the...
Read more >Math.Sin(double) returning incorrect result on .NET ...
I have put together a test case as proof. It passes on .NET Framework 4.5.1 and .NET Standard 1.5 (with a .NET Core...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Sergey-Terekhin just want to let you know that package has been created and available on nuget.
@Sergey-Terekhin Thank you for confirming the fix. We will create hot-fix package soon.