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

[otlp] Switch to TagWriter for handling of tags/attributes #5585

Merged
merged 4 commits into from
May 3, 2024

Conversation

CodeBlanch
Copy link
Member

Follow-up to #5476
Relates to #5475

Changes

  • Switch from TagTransformer to TagWriter design in OtlpExporter project

Details

See #5475 for information on why this is being done. The TL;DR version is this is set up to write directly onto a stream/buffer and skip all allocations completely (future work). Also there is more utilization of the base class/less duplication of logic in the tag handling for array values inside OtlpExporter code.

Merge requirement checklist

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

@CodeBlanch CodeBlanch added the pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package label May 1, 2024
@CodeBlanch CodeBlanch requested a review from a team as a code owner May 1, 2024 06:44
Copy link

codecov bot commented May 1, 2024

Codecov Report

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

Project coverage is 85.72%. Comparing base (6250307) to head (08843e7).
Report is 205 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5585      +/-   ##
==========================================
+ Coverage   83.38%   85.72%   +2.33%     
==========================================
  Files         297      271      -26     
  Lines       12531    11369    -1162     
==========================================
- Hits        10449     9746     -703     
+ Misses       2082     1623     -459     
Flag Coverage Δ
unittests ?
unittests-Instrumentation-Experimental 87.50% <ø> (?)
unittests-Instrumentation-Stable 87.50% <ø> (?)
unittests-Solution-Experimental 85.73% <98.68%> (?)
unittests-Solution-Stable 85.64% <98.68%> (?)
unittests-Unstable-Core 19.87% <ø> (?)

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

Files Coverage Δ
...metryProtocol/Implementation/ActivityExtensions.cs 96.13% <100.00%> (+0.20%) ⬆️
...rotocol/Implementation/OtlpLogRecordTransformer.cs 95.32% <100.00%> (+1.86%) ⬆️
...nTelemetryProtocol/Implementation/OtlpTagWriter.cs 100.00% <100.00%> (ø)
...metryProtocol/Implementation/ResourceExtensions.cs 100.00% <100.00%> (ø)
...tryProtocol/Implementation/MetricItemExtensions.cs 91.98% <75.00%> (+9.97%) ⬆️

... and 98 files with indirect coverage changes

@@ -80,7 +79,7 @@ internal abstract class TagWriter<TTagState, TArrayState>
default:
try
{
var stringValue = TruncateString(Convert.ToString(tag.Value, CultureInfo.InvariantCulture), tagValueMaxLength);
var stringValue = TruncateString(Convert.ToString(tag.Value/*TODO: , CultureInfo.InvariantCulture*/), tagValueMaxLength);
Copy link
Member

Choose a reason for hiding this comment

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

Curious, why is this changed to TODO?

Copy link
Member Author

Choose a reason for hiding this comment

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

The existing TagTransformer<T> we are migrating from doesn't use InvariantCulture today:

var stringValue = TruncateString(Convert.ToString(tag.Value), tagValueMaxLength);

There is a unit test in OtlpExporter which is adding a DateTime.UtcNow as a tag value. With this change to use InvariantCulture that test fails because the format changes.

I discussed a bit with @alanwest. We feel this is a bug. We should be using InvariantCulture in the transformation code. But it is also a breaking change. So the idea was let's do this migration to TagWriter<T> without changing that behavior. Then we can do a dedicated PR/fix for that after the migration so it is independent/clearly documented.

@CodeBlanch CodeBlanch merged commit ac0d1d1 into open-telemetry:main May 3, 2024
57 checks passed
@CodeBlanch CodeBlanch deleted the otlp-tagwriter branch May 3, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants