-
Notifications
You must be signed in to change notification settings - Fork 847
Use spans for serialization #6544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6544 +/- ##
==========================================
- Coverage 86.70% 86.46% -0.24%
==========================================
Files 258 258
Lines 11888 11648 -240
==========================================
- Hits 10308 10072 -236
+ Misses 1580 1576 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Hi @martincostello, @Kielek, can you help me here with the test failures? |
{ | ||
writePosition = WriteLogRecord(buffer, writePosition, sdkLimitOptions, experimentalOptions, logRecords[i]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the blank line back, and the style analyser won't fail the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it is good practice to run local build in Release
mode. Debug
allows to compile with Warnings, Release is extremely strict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad! Sorry!
I have fixed the style errors, but I still have a test failing:
Failed OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.OtlpAttributeTests.IntegralTypesSupported(value: [1, 2, 3]) [< 1 ms]
Error Message:
Google.Protobuf.InvalidProtocolBufferException : Protocol message contained an invalid tag (zero).
I can't figure out how this is related to my changes.
Runing the tests in debug mode I get this:
OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests.OtlpAttributeTests.IntegralTypesSupported(value: [1, 2, 3])
Source: OtlpAttributeTests.cs line 56
Duration: 7 ms
Message:
Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException : Method Debug.Fail failed with 'bytesWritten did not match numberOfUtf8CharsInString
', and was translated to Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException to avoid terminating the process hosting the test.
Stack Trace:
TestHostTraceListener.GetException(String message)
TestHostTraceListener.Fail(String message, String detailMessage)
TraceInternal.Fail(String message, String detailMessage)
Debug.Fail(String message, String detailMessage)
ProtobufOtlpTagWriter.TryWriteByteArrayTag(OtlpTagWriterState& state, String key, ReadOnlySpan`1 value) line 94
TagWriter`2.TryWriteTag(TTagState& state, String key, Object value, Nullable`1 tagValueMaxLength) line 70
TagWriter`2.TryWriteTag(TTagState& state, KeyValuePair`2 tag, Nullable`1 tagValueMaxLength) line 28
OtlpAttributeTests.TryTransformTag(KeyValuePair`2 tag, KeyValue& attribute) line 293
OtlpAttributeTests.IntegralTypesSupported(Object value) line 59
This happens because ProtobufOtlpTagWriter.TryWriteByteArrayTag
is calling ProtobufSerializer.WriteStringWithTag
with ProtobufOtlpCommonFieldNumberConstants.KeyValue_Key
(1) for numberOfUtf8CharsInString
with key
as "key"
.
What am I missing here?
a67075d
to
787412e
Compare
…ation, improving performance, memory efficiency, and code readability. Updated method signatures to eliminate explicit `writePosition` management, replaced incremental write logic with consistent `+=` operations, and streamlined encoding methods. Enhanced test coverage to validate edge cases and updated all test cases to align with the new implementation. Applied changes consistently across all serializers, ensuring backward compatibility and laying the groundwork for future optimizations. Improved error handling, debugging, and documentation for better maintainability and robustness.
This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day. |
Addresses #6543
Changes
Refactored serialization logic to use
Span<byte>
for buffer manipulation, improving performance, memory efficiency, and code readability. Updated method signatures to eliminate explicitwritePosition
management, replaced incremental write logic with consistent+=
operations, and streamlined encoding methods. Enhanced test coverage to validate edge cases and updated all test cases to align with the new implementation. Applied changes consistently across all serializers, ensuring backward compatibility and laying the groundwork for future optimizations. Improved error handling, debugging, and documentation for better maintainability and robustness.Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes