Skip to content

Commit

Permalink
Change metrics parsing to use InvariantCulture (#3558)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghord authored Dec 16, 2022
1 parent f1e33ea commit 60cdc98
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Tools/dotnet-counters/CounterMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Globalization;

namespace Microsoft.Diagnostics.Tools.Counters
{
Expand Down Expand Up @@ -165,7 +166,7 @@ private void HandleCounterRate(TraceEvent obj)
MeterInstrumentEventObserved(meterName, instrumentName, obj.TimeStamp);

// the value might be an empty string indicating no measurement was provided this collection interval
if (double.TryParse(rateText, out double rate))
if (double.TryParse(rateText, NumberStyles.Number | NumberStyles.Float, CultureInfo.InvariantCulture, out double rate))
{
CounterPayload payload = new RatePayload(meterName, instrumentName, null, unit, tags, rate, _interval, obj.TimeStamp);
_renderer.CounterPayloadReceived(payload, _pauseCmdSet);
Expand All @@ -189,7 +190,7 @@ private void HandleGauge(TraceEvent obj)
MeterInstrumentEventObserved(meterName, instrumentName, obj.TimeStamp);

// the value might be an empty string indicating no measurement was provided this collection interval
if (double.TryParse(lastValueText, out double lastValue))
if (double.TryParse(lastValueText, NumberStyles.Number | NumberStyles.Float, CultureInfo.InvariantCulture, out double lastValue))
{
CounterPayload payload = new GaugePayload(meterName, instrumentName, null, unit, tags, lastValue, obj.TimeStamp);
_renderer.CounterPayloadReceived(payload, _pauseCmdSet);
Expand Down Expand Up @@ -305,11 +306,11 @@ private static KeyValuePair<double, double>[] ParseQuantiles(string quantileList
{
continue;
}
if (!double.TryParse(keyValParts[0], out double key))
if (!double.TryParse(keyValParts[0], NumberStyles.Number | NumberStyles.Float, CultureInfo.InvariantCulture, out double key))
{
continue;
}
if (!double.TryParse(keyValParts[1], out double val))
if (!double.TryParse(keyValParts[1], NumberStyles.Number | NumberStyles.Float, CultureInfo.InvariantCulture, out double val))
{
continue;
}
Expand Down

0 comments on commit 60cdc98

Please sign in to comment.