Skip to content

Commit 86cd564

Browse files
author
Anuraag Agrawal
authored
Deprecate StatusData.isUnset (#2500)
* Deprecate StatusData.isUnset * Cleanup * option 2
1 parent b68fc82 commit 86cd564

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

exporters/jaeger-thrift/src/main/java/io/opentelemetry/exporter/jaeger/thrift/Adapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static Span toJaeger(SpanData span) {
104104
.setVStr(span.getStatus().getDescription()));
105105
}
106106

107-
if (!span.getStatus().isUnset()) {
107+
if (span.getStatus().getStatusCode() != StatusCode.UNSET) {
108108
tags.add(
109109
new Tag(KEY_SPAN_STATUS_CODE, TagType.STRING)
110110
.setVStr(span.getStatus().getStatusCode().name()));

exporters/jaeger/src/main/java/io/opentelemetry/exporter/jaeger/Adapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static Model.Span toJaeger(SpanData span) {
104104
.build());
105105
}
106106

107-
if (!span.getStatus().isUnset()) {
107+
if (span.getStatus().getStatusCode() != StatusCode.UNSET) {
108108
target.addTags(
109109
Model.KeyValue.newBuilder()
110110
.setKey(KEY_SPAN_STATUS_CODE)

exporters/zipkin/src/main/java/io/opentelemetry/exporter/zipkin/ZipkinSpanExporter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.opentelemetry.api.common.AttributeType;
1313
import io.opentelemetry.api.common.Attributes;
1414
import io.opentelemetry.api.trace.Span.Kind;
15+
import io.opentelemetry.api.trace.StatusCode;
1516
import io.opentelemetry.sdk.common.CompletableResultCode;
1617
import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
1718
import io.opentelemetry.sdk.resources.ResourceAttributes;
@@ -131,11 +132,11 @@ static Span generateSpan(SpanData spanData, Endpoint localEndpoint) {
131132
StatusData status = spanData.getStatus();
132133

133134
// include status code & error.
134-
if (!status.isUnset()) {
135+
if (status.getStatusCode() != StatusCode.UNSET) {
135136
spanBuilder.putTag(OTEL_STATUS_CODE, status.getStatusCode().toString());
136137

137138
// add the error tag, if it isn't already in the source span.
138-
if (!status.isOk() && spanAttributes.get(STATUS_ERROR) == null) {
139+
if (status.getStatusCode() == StatusCode.ERROR && spanAttributes.get(STATUS_ERROR) == null) {
139140
spanBuilder.putTag(STATUS_ERROR.getKey(), nullToEmpty(status.getDescription()));
140141
}
141142
}

sdk-extensions/zpages/src/main/java/io/opentelemetry/sdk/extension/zpages/TracezSpanBuckets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class TracezSpanBuckets {
3131

3232
void addToBucket(ReadableSpan span) {
3333
StatusData status = span.toSpanData().getStatus();
34-
if (status.isOk()) {
34+
if (status.getStatusCode() != StatusCode.ERROR) {
3535
latencyBuckets.get(LatencyBoundary.getBoundary(span.getLatencyNanos())).add(span);
3636
return;
3737
}

sdk/trace/src/main/java/io/opentelemetry/sdk/trace/data/StatusData.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ static StatusData create(StatusCode code, @Nullable String description) {
5656
* Returns {@code true} if this {@code Status} is UNSET, i.e., not an error.
5757
*
5858
* @return {@code true} if this {@code Status} is UNSET.
59+
* @deprecated Compare {@link #getStatusCode()} with {@link StatusCode#UNSET}
5960
*/
6061
// TODO: Consider to remove this in a future PR. Avoid too many changes in the initial PR.
62+
@Deprecated
6163
default boolean isUnset() {
6264
return StatusCode.UNSET == getStatusCode();
6365
}
@@ -67,8 +69,9 @@ default boolean isUnset() {
6769
* overridden to be ok by an operator.
6870
*
6971
* @return {@code true} if this {@code Status} is OK or UNSET.
72+
* @deprecated Compare {@link #getStatusCode()} with {@link StatusCode#ERROR}
7073
*/
71-
// TODO: Consider to remove this in a future PR. Avoid too many changes in the initial PR.
74+
@Deprecated
7275
default boolean isOk() {
7376
return isUnset() || StatusCode.OK == getStatusCode();
7477
}

0 commit comments

Comments
 (0)