Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Notes](../../RELEASENOTES.md).
}
```

* When using the `OTEL_TRACES_SAMPLER_ARG` variable with the `OTEL_TRACES_SAMPLER` variable set to `traceidratio`, the value will be parsed invariantly of the culture of the local machine. Only `.` can now be used as the decimal delimiter for its value.

## 1.12.0

Released 2025-Apr-29
Expand Down
3 changes: 2 additions & 1 deletion src/OpenTelemetry/Trace/TracerProviderSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -458,7 +459,7 @@ private static Sampler GetSampler(IConfiguration configuration, Sampler? stateSa
private static double ReadTraceIdRatio(IConfiguration configuration)
{
if (configuration.TryGetStringValue(TracesSamplerArgConfigKey, out var configValue) &&
double.TryParse(configValue, out var traceIdRatio))
double.TryParse(configValue, NumberStyles.Float | NumberStyles.AllowThousands, CultureInfo.InvariantCulture, out var traceIdRatio))
{
return traceIdRatio;
}
Expand Down
15 changes: 4 additions & 11 deletions test/OpenTelemetry.Tests/Logs/LogRecordTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@ public void CheckStateForStructuredLogWithGeneralType(bool includeFormattedMessa
{
using var loggerFactory = InitializeLoggerFactory(out List<LogRecord> exportedItems, configure: o => o.IncludeFormattedMessage = includeFormattedMessage);
var logger = loggerFactory.CreateLogger<LogRecordTests>();
var trufflePrice = 299.99;

var food = new Dictionary<string, object>
{
["Name"] = "truffle",
["Price"] = 299.99,
["Price"] = trufflePrice,
};
logger.Food(food);

Expand All @@ -276,16 +277,8 @@ public void CheckStateForStructuredLogWithGeneralType(bool includeFormattedMessa
Assert.Equal("{Food}", exportedItems[0].Body);
if (includeFormattedMessage)
{
var prevCulture = CultureInfo.CurrentCulture;
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
try
{
Assert.Equal("[Name, truffle], [Price, 299.99]", exportedItems[0].FormattedMessage);
}
finally
{
CultureInfo.CurrentCulture = prevCulture;
}
var priceInCurrentCulture = trufflePrice.ToString(CultureInfo.CurrentCulture);
Assert.Equal($"[Name, truffle], [Price, {priceInCurrentCulture}]", exportedItems[0].FormattedMessage);
}
else
{
Expand Down