question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Broken double value representation under .Net Core

See original GitHub issue

Hello! 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sanych-suncommented, Sep 4, 2019

@Sergey-Terekhin just want to let you know that package has been created and available on nuget.

1reaction
sanych-suncommented, Sep 3, 2019

@Sergey-Terekhin Thank you for confirming the fix. We will create hot-fix package soon.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found