Skip to content

Commit

Permalink
Merge branch 'main' into repo-sampling-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch authored Jan 27, 2025
2 parents 3e075c0 + cd8cb41 commit a27931e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void WriteStringWithTag_ASCIIString_WritesCorrectly()
Assert.Equal(10, buffer[0]); // Tag
Assert.Equal(5, buffer[1]); // Length

byte[] expectedContent = Encoding.ASCII.GetBytes("Hello");
byte[] expectedContent = "Hello"u8.ToArray();
byte[] actualContent = new byte[5];
Array.Copy(buffer, 2, actualContent, 0, 5);
Assert.True(expectedContent.SequenceEqual(actualContent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void SelfDiagnosticsEventListener_EncodeInBuffer_EnoughSpace()

// '\n' will be appended to the original string "abc" after EncodeInBuffer is called.
// The byte where '\n' will be placed should not be touched within EncodeInBuffer, so it stays as '\0'.
byte[] expected = Encoding.UTF8.GetBytes("abc\0");
byte[] expected = "abc\0"u8.ToArray();
AssertBufferOutput(expected, buffer, startPos, endPos + 1);
}

Expand All @@ -204,7 +204,7 @@ public void SelfDiagnosticsEventListener_EncodeInBuffer_NotEnoughSpaceForFullStr
// It's a quick estimate by assumption that most Unicode characters takes up to 2 16-bit UTF-16 chars,
// which can be up to 4 bytes when encoded in UTF-8.
int endPos = SelfDiagnosticsEventListener.EncodeInBuffer("abc", false, buffer, startPos);
byte[] expected = Encoding.UTF8.GetBytes("ab...\0");
byte[] expected = "ab...\0"u8.ToArray();
AssertBufferOutput(expected, buffer, startPos, endPos + 1);
}

Expand All @@ -214,7 +214,7 @@ public void SelfDiagnosticsEventListener_EncodeInBuffer_NotEvenSpaceForTruncated
byte[] buffer = new byte[20];
int startPos = buffer.Length - Ellipses.Length; // Just enough space for "...\n".
int endPos = SelfDiagnosticsEventListener.EncodeInBuffer("abc", false, buffer, startPos);
byte[] expected = Encoding.UTF8.GetBytes("...\0");
byte[] expected = "...\0"u8.ToArray();
AssertBufferOutput(expected, buffer, startPos, endPos + 1);
}

Expand All @@ -233,7 +233,7 @@ public void SelfDiagnosticsEventListener_EncodeInBuffer_IsParameter_EnoughSpace(
byte[] buffer = new byte[20];
int startPos = buffer.Length - EllipsesWithBrackets.Length - 6; // Just enough space for "abc" even if "...\n" need to be added.
int endPos = SelfDiagnosticsEventListener.EncodeInBuffer("abc", true, buffer, startPos);
byte[] expected = Encoding.UTF8.GetBytes("{abc}\0");
byte[] expected = "{abc}\0"u8.ToArray();
AssertBufferOutput(expected, buffer, startPos, endPos + 1);
}

Expand All @@ -243,7 +243,7 @@ public void SelfDiagnosticsEventListener_EncodeInBuffer_IsParameter_NotEnoughSpa
byte[] buffer = new byte[20];
int startPos = buffer.Length - EllipsesWithBrackets.Length - 5; // Just not space for "...\n".
int endPos = SelfDiagnosticsEventListener.EncodeInBuffer("abc", true, buffer, startPos);
byte[] expected = Encoding.UTF8.GetBytes("{ab...}\0");
byte[] expected = "{ab...}\0"u8.ToArray();
AssertBufferOutput(expected, buffer, startPos, endPos + 1);
}

Expand All @@ -253,7 +253,7 @@ public void SelfDiagnosticsEventListener_EncodeInBuffer_IsParameter_NotEvenSpace
byte[] buffer = new byte[20];
int startPos = buffer.Length - EllipsesWithBrackets.Length; // Just enough space for "{...}\n".
int endPos = SelfDiagnosticsEventListener.EncodeInBuffer("abc", true, buffer, startPos);
byte[] expected = Encoding.UTF8.GetBytes("{...}\0");
byte[] expected = "{...}\0"u8.ToArray();
AssertBufferOutput(expected, buffer, startPos, endPos + 1);
}

Expand Down
8 changes: 4 additions & 4 deletions test/OpenTelemetry.Tests/Trace/SpanContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace OpenTelemetry.Trace.Tests;

public class SpanContextTest
{
private static readonly byte[] FirstTraceIdBytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)'a' };
private static readonly byte[] SecondTraceIdBytes = { 0, 0, 0, 0, 0, 0, 0, (byte)'0', 0, 0, 0, 0, 0, 0, 0, 0 };
private static readonly byte[] FirstSpanIdBytes = { 0, 0, 0, 0, 0, 0, 0, (byte)'a' };
private static readonly byte[] SecondSpanIdBytes = { (byte)'0', 0, 0, 0, 0, 0, 0, 0 };
private static readonly byte[] FirstTraceIdBytes = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0a"u8.ToArray();
private static readonly byte[] SecondTraceIdBytes = "\0\0\0\0\0\0\00\0\0\0\0\0\0\0\0"u8.ToArray();
private static readonly byte[] FirstSpanIdBytes = "\0\0\0\0\0\0\0a"u8.ToArray();
private static readonly byte[] SecondSpanIdBytes = "0\0\0\0\0\0\0\0"u8.ToArray();

private static readonly SpanContext First =
new(
Expand Down

0 comments on commit a27931e

Please sign in to comment.