Skip to content

OTLP Span arrays allow exporting null values + support for long arrays#1919

Merged
cijothomas merged 16 commits into
open-telemetry:mainfrom
Austin-Tan:SetTagNullStringArray
Mar 26, 2021
Merged

OTLP Span arrays allow exporting null values + support for long arrays#1919
cijothomas merged 16 commits into
open-telemetry:mainfrom
Austin-Tan:SetTagNullStringArray

Conversation

@Austin-Tan

@Austin-Tan Austin-Tan commented Mar 17, 2021

Copy link
Copy Markdown
Member

Fixes #1843 .

  1. For all string and supported primitive arrays (bool[], double[], long[]) allowed null values to be exported.
  2. long arrays were not previously supported (only int[]), they are now.
  • CHANGELOG.md updated for non-trivial changes

@Austin-Tan Austin-Tan requested a review from a team March 17, 2021 20:11
@codecov

codecov Bot commented Mar 17, 2021

Copy link
Copy Markdown

Codecov Report

Merging #1919 (14ef89b) into main (0208fd6) will increase coverage by 0.68%.
The diff coverage is 76.92%.

❗ Current head 14ef89b differs from pull request most recent head 7d2622e. Consider uploading reports for the commit 7d2622e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1919      +/-   ##
==========================================
+ Coverage   83.69%   84.38%   +0.68%     
==========================================
  Files         192      188       -4     
  Lines        6159     6117      -42     
==========================================
+ Hits         5155     5162       +7     
+ Misses       1004      955      -49     
Impacted Files Coverage Δ
...metryProtocol/Implementation/ActivityExtensions.cs 86.30% <76.92%> (-0.60%) ⬇️
...rc/OpenTelemetry/Trace/TracerProviderBuilderSdk.cs 89.83% <0.00%> (-10.17%) ⬇️
...ZPages/Implementation/ZPagesExporterEventSource.cs 56.25% <0.00%> (-6.25%) ⬇️
...c/OpenTelemetry.Api/Trace/TracerProviderBuilder.cs 100.00% <0.00%> (ø)
...c/OpenTelemetry/Trace/TracerProviderBuilderBase.cs
...ing/Implementation/TracerProviderBuilderHosting.cs
...penTelemetry/Internal/ServiceProviderExtensions.cs
...s.Hosting/Trace/TracerProviderBuilderExtensions.cs
....Exporter.Jaeger/JaegerExporterHelperExtensions.cs 15.38% <0.00%> (+4.27%) ⬆️
....Exporter.Zipkin/ZipkinExporterHelperExtensions.cs 15.38% <0.00%> (+4.27%) ⬆️
... and 3 more

using var rootActivity = activitySource.StartActivity("root", ActivityKind.Client);

var stringArr = new string[] { "test", null };
var longArr = new long?[] { 1, null };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what happens to this null element ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I removed the tests for nullable primtive type arrays like long?[] and double?[]. I think discussion of them is outside the scope of this PR

@CodeBlanch CodeBlanch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Austin-Tan Austin-Tan closed this Mar 22, 2021
@Austin-Tan Austin-Tan reopened this Mar 22, 2021
@Austin-Tan Austin-Tan closed this Mar 22, 2021
@Austin-Tan Austin-Tan reopened this Mar 22, 2021
@Austin-Tan Austin-Tan closed this Mar 22, 2021
@Austin-Tan Austin-Tan reopened this Mar 22, 2021
@Austin-Tan Austin-Tan changed the title String Arrays in OTLP spans change Null to string.Empty OTLP Span arrays allow exporting null values Mar 25, 2021
@Austin-Tan Austin-Tan changed the title OTLP Span arrays allow exporting null values OTLP Span arrays allow exporting null values + support for long arrays Mar 25, 2021
@cijothomas cijothomas merged commit d7bb2b9 into open-telemetry:main Mar 26, 2021
@Oberon00

Copy link
Copy Markdown
Member

I think 41b3eef needs to be reverted. Copying my comment from #1939 (comment):

Hi! The spec says that nulls in arrays are invalid and you should only allow them if the language does not make it possible to prevent them at compile-time. So explicitly using double? [] etc instead of double[] violates the spec. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attributes

null values SHOULD NOT be allowed in arrays.

only then does the spec also say:

However, if it is impossible to make sure that no null values are accepted (e.g. in languages that do not have appropriate compile-time type checking) ...

But in C# this only applies to strings.

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.

Setting Activity tag with a String Array which contains a null crashes the application.

4 participants