[Exporter.Prometheus] Fix number formatting
Merged
MA
3mo ago+630+630+012345678901234567890123456789-182-182-012345678901234567890123456789
Fixes #7585
Changes
Fix incorrectly formatted floating point numbers caused by a misunderstanding of Canonical Numbers.
Specifically this part:
A warning to implementers in C and other languages that share its printf implementation: The standard precision of %f, %e and %g is only six significant digits. 17 significant digits are required for full precision, e.g. printf("%.17g", d).
I took it to mean to use G17 to format things, but that over-specifies the precision and causes non-exact round-tripping issues as described in the linked discussion.
Re-running the benchmarks locally don't show any regression in terms of runtime or allocation due to the use of stackalloc.
Merge requirement checklist
- CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
- Unit tests added/updated
- Appropriate
CHANGELOG.mdfiles updated for non-trivial changes - Changes in public API reviewed (if applicable)