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 / invalid spancontext and handle null attributes for links. #2985

Merged
merged 3 commits into from
Mar 7, 2021

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Mar 5, 2021

if (spanContext == null || !spanContext.isValid()) {
return this;
}
if (!spanContext.isValid()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is redundant with the check above, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops

@@ -83,12 +83,24 @@ public SpanBuilder setSpanKind(SpanKind spanKind) {

@Override
public SpanBuilder addLink(SpanContext spanContext) {
if (spanContext == null || !spanContext.isValid()) {
return this;
}
addLink(LinkData.create(spanContext));
return this;
}

@Override
public SpanBuilder addLink(SpanContext spanContext, Attributes attributes) {
Copy link
Member

@bogdandrutu bogdandrutu Mar 6, 2021

Choose a reason for hiding this comment

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

Should we also document in the API, same as you did in the specs:

"Implementation MAY 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.

Sure

Anuraag Agrawal added 2 commits March 7, 2021 14:43
@jkwatson jkwatson merged commit f113c03 into open-telemetry:main Mar 7, 2021
This was referenced Dec 19, 2021
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.

Adding an invalid span as a link
3 participants