diff --git a/CHANGELOG.md b/CHANGELOG.md
index f302bb5e53..5deb951993 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@
### Fixes
- Fixed JNI Error when accessing Android device data from multiple threads ([#3802](https://github.com/getsentry/sentry-dotnet/pull/3802))
+- Fix "System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'idData')" error propagating OpenTelemetry span ids ([#3850](https://github.com/getsentry/sentry-dotnet/pull/3850))
### Dependencies
diff --git a/src/Sentry/SpanId.cs b/src/Sentry/SpanId.cs
index a4e1062a40..0548d75d53 100644
--- a/src/Sentry/SpanId.cs
+++ b/src/Sentry/SpanId.cs
@@ -41,7 +41,7 @@ namespace Sentry;
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(_value);
///
- public override string ToString() => _value.ToString("x8");
+ public override string ToString() => _value.ToString("x8").PadLeft(16, '0');
///
/// Generates a new Sentry ID.
diff --git a/test/Sentry.Tests/Protocol/Context/TraceTests.cs b/test/Sentry.Tests/Protocol/Context/TraceTests.cs
index 46bcf7d930..27372d0d9a 100644
--- a/test/Sentry.Tests/Protocol/Context/TraceTests.cs
+++ b/test/Sentry.Tests/Protocol/Context/TraceTests.cs
@@ -85,4 +85,15 @@ public void Clone_CopyValues()
Assert.Equal(trace.SpanId, clone.SpanId);
Assert.Equal(trace.TraceId, clone.TraceId);
}
+
+ [Fact]
+ public void SpanId_LeadingZero_ToStringValid()
+ {
+ // Arrange
+ const string spanIdInput = "0ecd6f15f72015cb";
+ var spanId = new SpanId(spanIdInput);
+
+ // Assert
+ Assert.Equal(spanIdInput, spanId.ToString());
+ }
}