Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Notes](../../RELEASENOTES.md).
}
```

* Fixed parsing of `OTEL_TRACES_SAMPLER_ARG` decimal values to always use `.`
as the delimiter when using the `traceidratio` sampler, preventing
locale-specific parsing issues.
([#6444](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6444))

## 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
Loading