Skip to content
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

[shared] Remove TagTransformer and improve TagWriter #5602

Conversation

CodeBlanch
Copy link
Member

Follow-up to #5476
Relates to #5475

Changes

  • Removes TagTransformer as everything is now using TagWriter
  • Converts JsonStringArray tests to use TagWriter and fix bugs that manifested
  • Uses ReadOnlySpan<char> for strings in TagWriter to make it possible to bypass allocations when writing chars orstrings which get trimmed due to length limits

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated

@CodeBlanch CodeBlanch requested a review from a team as a code owner May 10, 2024 05:17
Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 85.69%. Comparing base (6250307) to head (f2adebc).
Report is 223 commits behind head on main.

❗ Current head f2adebc differs from pull request most recent head eb86a50. Consider uploading reports for the commit eb86a50 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5602      +/-   ##
==========================================
+ Coverage   83.38%   85.69%   +2.30%     
==========================================
  Files         297      254      -43     
  Lines       12531    10979    -1552     
==========================================
- Hits        10449     9408    -1041     
+ Misses       2082     1571     -511     
Flag Coverage Δ
unittests ?
unittests-Solution-Experimental 85.64% <66.66%> (?)
unittests-Solution-Stable 85.65% <66.66%> (?)
unittests-Unstable-Core 19.91% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...nTelemetryProtocol/Implementation/OtlpTagWriter.cs 100.00% <100.00%> (ø)
....Exporter.Zipkin/Implementation/ZipkinTagWriter.cs 63.63% <ø> (ø)
...xporter.Console/Implementation/ConsoleTagWriter.cs 11.53% <0.00%> (ø)

... and 112 files with indirect coverage changes

case string?[] stringArray: this.WriteStringsToArray(ref arrayState, stringArray, tagValueMaxLength); break;
case bool[] boolArray: this.WriteStructToArray(ref arrayState, boolArray); break;
case byte[] byteArray: this.WriteToArrayCovariant(ref arrayState, byteArray); break;
case short[] shortArray: this.WriteToArrayCovariant(ref arrayState, shortArray); break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why some of the entries like ushortArray checks were removed. Are these types not expected here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is covered with WriteToArrayTypeChecked. Is there a benefit of splitting it out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of an interesting situation. Check out this fiddle: https://dotnetfiddle.net/xLeGFw

Basically runtime treats sbyte[]/byte[], int[]/uint[], short[]/ushort[], and long[]/ulong[] as the same types when it comes to is. The way the code was written before we wouldn't hit all the branches, whichever was first for one of those pairs would win and we would end up casting wrong. Like sbyte[] falls into byte[] which means values like -128 ((sbyte)0x80) becomes 128 ((byte)0x80).

Copy link
Contributor

@rajkumar-rangaraj rajkumar-rangaraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@CodeBlanch CodeBlanch merged commit cf8ca09 into open-telemetry:main May 14, 2024
43 checks passed
@CodeBlanch CodeBlanch deleted the shared-tagwriter-cleanup-and-improvements branch May 14, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants