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

Make setting null-valued attributes a no-op, and document that their behavior is undefined. #1706

Merged
merged 5 commits into from
Sep 30, 2020

Conversation

jkwatson
Copy link
Contributor

resolves #1703

@codecov
Copy link

codecov bot commented Sep 25, 2020

Codecov Report

Merging #1706 into master will decrease coverage by 0.21%.
The diff coverage is 28.57%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1706      +/-   ##
============================================
- Coverage     85.48%   85.27%   -0.22%     
+ Complexity     1380     1376       -4     
============================================
  Files           164      164              
  Lines          5402     5386      -16     
  Branches        559      554       -5     
============================================
- Hits           4618     4593      -25     
- Misses          586      591       +5     
- Partials        198      202       +4     
Impacted Files Coverage Δ Complexity Δ
api/src/main/java/io/opentelemetry/trace/Span.java 100.00% <ø> (ø) 1.00 <0.00> (ø)
...java/io/opentelemetry/sdk/trace/AttributesMap.java 83.33% <0.00%> (-13.10%) 12.00 <3.00> (-1.00)
...ava/io/opentelemetry/sdk/trace/SpanBuilderSdk.java 96.84% <ø> (-0.07%) 31.00 <0.00> (-1.00)
.../main/java/io/opentelemetry/common/Attributes.java 92.00% <25.00%> (-4.78%) 18.00 <0.00> (ø)
...ntelemetry/sdk/trace/RecordEventsReadableSpan.java 81.09% <100.00%> (-0.73%) 75.00 <8.00> (-2.00)
...y/sdk/metrics/aggregator/DoubleMinMaxSumCount.java 96.07% <0.00%> (-3.93%) 6.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7706d6...6d5a64d. Read the comment docs.

builder.setAttribute(key, value);
}
});
attributes.forEach(builder::setAttribute);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

attributes.setAttribute("arrayLong", (Long[]) null);
attributes.setAttribute("arrayDouble", (Double[]) null);
attributes.setAttribute("arrayBool", (Boolean[]) null);
assertThat(attributes.build().size()).isEqualTo(3);
Copy link
Member

Choose a reason for hiding this comment

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

should we check that we implement a no-op behavior instead of leaving it undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went back and forth on this. I'm not really sure which we should do, since we're explicitly saying that behavior is undefined. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

If undefined, don't test for it. Some may consider tests as a kind of documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that was my thinking as well.

Copy link
Member

@thisthat thisthat Sep 28, 2020

Choose a reason for hiding this comment

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

I would argue that the specification says "undefined behavior", i.e. each implementation of the spec can do whatever they prefer, but the OTel SDK has a well-defined behavior. IMHO we should verify that we implement correctly the no-op behavior in every point that touches null attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a test that validates the current behavior, with a clear message that it's not required behavior and would be fine to be changed.

Copy link
Member

@Oberon00 Oberon00 Sep 28, 2020

Choose a reason for hiding this comment

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

@thisthat As a C++ dev, I'd say that would be "implementation-defined" behavior, not undefined behavior 😀

@jkwatson jkwatson force-pushed the null_valued_attributes branch from c1147db to 2761a09 Compare September 28, 2020 17:39
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.

Update null value handling for span and resource attributes
5 participants