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

Ignore null or blank string-valued span attributes. #771

Conversation

jkwatson
Copy link
Contributor

resolves #765

@codecov-io
Copy link

codecov-io commented Jan 17, 2020

Codecov Report

Merging #771 into master will increase coverage by 0.2%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #771     +/-   ##
===========================================
+ Coverage     78.77%   78.97%   +0.2%     
- Complexity      760      769      +9     
===========================================
  Files            98       98             
  Lines          2709     2711      +2     
  Branches        255      257      +2     
===========================================
+ Hits           2134     2141      +7     
+ Misses          474      470      -4     
+ Partials        101      100      -1
Impacted Files Coverage Δ Complexity Δ
api/src/main/java/io/opentelemetry/trace/Span.java 100% <ø> (ø) 0 <0> (ø) ⬇️
...ain/java/io/opentelemetry/trace/DefaultTracer.java 95.45% <ø> (-0.11%) 7 <0> (ø)
.../main/java/io/opentelemetry/trace/DefaultSpan.java 76% <ø> (+5.41%) 18 <0> (+1) ⬆️
...ava/io/opentelemetry/sdk/trace/SpanBuilderSdk.java 93.93% <100%> (+0.12%) 37 <0> (+2) ⬆️
...in/java/io/opentelemetry/internal/StringUtils.java 83.33% <100%> (+3.33%) 8 <3> (+3) ⬆️
...ntelemetry/sdk/trace/RecordEventsReadableSpan.java 91.56% <100%> (+1.32%) 46 <0> (+3) ⬆️
...in/java/io/opentelemetry/trace/AttributeValue.java 73.33% <100%> (-0.87%) 5 <0> (ø)

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 ba17e1f...0e77fcb. Read the comment docs.

@tylerbenson
Copy link
Member

What about setting an attribute on a started span, not the span builder?

@jkwatson
Copy link
Contributor Author

great catch. will update the RERS as well.

@jkwatson
Copy link
Contributor Author

@tylerbenson ok, got the active span as well

@@ -137,6 +138,9 @@

@Override
public Span.Builder setAttribute(String key, String value) {
if (StringUtils.isNullOrBlank(value)) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to count this as dropped or we simply ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's definitely a different kind of "dropping" than the "too many attributes" kind. I think ignoring it is fine..it's not really an attribute at all without a value.

Copy link
Member

Choose a reason for hiding this comment

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

Fine with this for the moment, may be unexpected for users especially for empty.

@@ -137,6 +138,9 @@

@Override
public Span.Builder setAttribute(String key, String value) {
if (StringUtils.isNullOrBlank(value)) {
return this;
}
return setAttribute(key, AttributeValue.stringAttributeValue(value));
Copy link
Member

Choose a reason for hiding this comment

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

What is the behavior for AttributeValue.stringAttributeValue(value) in case a null string is passed?

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 remains the same. If you're trying to create an AttributeValue with a null, you'll get the usual NPE.

Copy link
Member

Choose a reason for hiding this comment

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

k

Copy link
Member

Choose a reason for hiding this comment

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

I think this is unexpected result and inconsistent, maybe we should try to see how we can offer the same behavior.

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's a fair comment. I think we can do this by allowing null/empty in the AttributeValue, and then ignoring when we try to add. I'll change this PR to do it that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, changed

@@ -137,6 +138,9 @@

@Override
public Span.Builder setAttribute(String key, String value) {
if (StringUtils.isNullOrBlank(value)) {
Copy link
Member

Choose a reason for hiding this comment

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

Fine with this for the moment, may be unexpected for users especially for empty.

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.

Span::setAttribute null-checking of value may be detrimental
5 participants