Skip to content

Commit b283298

Browse files
authored
fix: Ensure span ids are 16 characters (#3850)
1 parent 50251b2 commit b283298

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
### Fixes
1111
- Fixed JNI Error when accessing Android device data from multiple threads ([#3802](https://github.com/getsentry/sentry-dotnet/pull/3802))
12+
- 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))
1213

1314
### Dependencies
1415

src/Sentry/SpanId.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace Sentry;
4141
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(_value);
4242

4343
/// <inheritdoc />
44-
public override string ToString() => _value.ToString("x8");
44+
public override string ToString() => _value.ToString("x8").PadLeft(16, '0');
4545

4646
/// <summary>
4747
/// Generates a new Sentry ID.

test/Sentry.Tests/Protocol/Context/TraceTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,15 @@ public void Clone_CopyValues()
8585
Assert.Equal(trace.SpanId, clone.SpanId);
8686
Assert.Equal(trace.TraceId, clone.TraceId);
8787
}
88+
89+
[Fact]
90+
public void SpanId_LeadingZero_ToStringValid()
91+
{
92+
// Arrange
93+
const string spanIdInput = "0ecd6f15f72015cb";
94+
var spanId = new SpanId(spanIdInput);
95+
96+
// Assert
97+
Assert.Equal(spanIdInput, spanId.ToString());
98+
}
8899
}

0 commit comments

Comments
 (0)