Set status based on error, either true or false. (#227)

This commit is contained in:
Carlos Alberto Cortez 2019-04-30 17:57:20 +02:00 committed by GitHub
parent fad1d489b9
commit 1421c9482e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 10 deletions

View File

@ -121,9 +121,7 @@ final class SpanBuilderShim implements SpanBuilder {
break;
}
} else if (Tags.ERROR.getKey().equals(key)) {
if (Boolean.parseBoolean(value)) {
error = true;
}
error = Boolean.parseBoolean(value);
} else {
this.spanBuilderAttributeKeys.add(key);
this.spanBuilderAttributeValues.add(AttributeValue.stringAttributeValue(value));
@ -135,9 +133,7 @@ final class SpanBuilderShim implements SpanBuilder {
@Override
public SpanBuilder withTag(String key, boolean value) {
if (Tags.ERROR.getKey().equals(key)) {
if (value) {
error = true;
}
error = value;
} else {
this.spanBuilderAttributeKeys.add(key);
this.spanBuilderAttributeValues.add(AttributeValue.booleanAttributeValue(value));

View File

@ -51,8 +51,9 @@ final class SpanShim implements Span {
if (Tags.SPAN_KIND.getKey().equals(key)) {
// TODO: confirm we can safely ignore span.kind after Span was created
// https://github.com/bogdandrutu/openconsensus/issues/42
} else if (Tags.ERROR.getKey().equals(key) && Boolean.parseBoolean(value)) {
this.span.setStatus(Status.UNKNOWN);
} else if (Tags.ERROR.getKey().equals(key)) {
Status status = Boolean.parseBoolean(value) ? Status.UNKNOWN : Status.OK;
span.setStatus(status);
} else {
span.setAttribute(key, value);
}
@ -62,8 +63,9 @@ final class SpanShim implements Span {
@Override
public Span setTag(String key, boolean value) {
if (Tags.ERROR.getKey().equals(key) && value) {
this.span.setStatus(Status.UNKNOWN);
if (Tags.ERROR.getKey().equals(key)) {
Status status = value ? Status.UNKNOWN : Status.OK;
span.setStatus(status);
} else {
span.setAttribute(key, value);
}