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

View File

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