Skip to content

Commit f071768

Browse files
committed
opencensus-shim
1 parent 19f8996 commit f071768

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/DelegatingSpan.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.google.errorprone.annotations.MustBeClosed;
99
import io.opentelemetry.api.common.AttributeKey;
1010
import io.opentelemetry.api.common.Attributes;
11+
import io.opentelemetry.api.common.Value;
1112
import io.opentelemetry.api.trace.Span;
1213
import io.opentelemetry.api.trace.SpanContext;
1314
import io.opentelemetry.api.trace.StatusCode;
@@ -77,6 +78,11 @@ default Span setAttribute(String key, boolean value) {
7778
return getDelegate().setAttribute(key, value);
7879
}
7980

81+
@Override
82+
default Span setAttribute(String key, Value<?> value) {
83+
return getDelegate().setAttribute(key, value);
84+
}
85+
8086
@Override
8187
default Span setAttribute(AttributeKey<Long> key, int value) {
8288
return getDelegate().setAttribute(key, value);

opencensus-shim/src/main/java/io/opentelemetry/opencensusshim/OpenTelemetryNoRecordEventsSpanImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import io.opencensus.trace.Status;
3434
import io.opentelemetry.api.common.AttributeKey;
3535
import io.opentelemetry.api.common.Attributes;
36+
import io.opentelemetry.api.common.Value;
3637
import io.opentelemetry.api.trace.StatusCode;
3738
import java.util.EnumSet;
3839
import java.util.Map;
@@ -129,6 +130,11 @@ public io.opentelemetry.api.trace.Span setAttribute(String key, boolean value) {
129130
return this;
130131
}
131132

133+
@Override
134+
public io.opentelemetry.api.trace.Span setAttribute(String key, Value<?> value) {
135+
return this;
136+
}
137+
132138
@Override
133139
public <T> io.opentelemetry.api.trace.Span setAttribute(AttributeKey<T> key, @Nullable T value) {
134140
return this;

opencensus-shim/src/test/java/io/opentelemetry/opencensusshim/DelegatingSpanTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import io.opentelemetry.api.common.AttributeKey;
1212
import io.opentelemetry.api.common.Attributes;
13+
import io.opentelemetry.api.common.Value;
1314
import io.opentelemetry.api.trace.Span;
1415
import io.opentelemetry.api.trace.SpanContext;
1516
import io.opentelemetry.api.trace.StatusCode;
@@ -95,6 +96,7 @@ static Stream<Arguments> delegateMethodsProvider() {
9596
Arguments.of("setAttribute", new Class<?>[] {String.class, long.class}, times(1)),
9697
Arguments.of("setAttribute", new Class<?>[] {String.class, double.class}, times(1)),
9798
Arguments.of("setAttribute", new Class<?>[] {String.class, boolean.class}, times(1)),
99+
Arguments.of("setAttribute", new Class<?>[] {String.class, Value.class}, times(1)),
98100
Arguments.of(
99101
"recordException", new Class<?>[] {Throwable.class, Attributes.class}, times(1)),
100102
Arguments.of("recordException", new Class<?>[] {Throwable.class}, times(1)),

opencensus-shim/src/test/java/io/opentelemetry/opencensusshim/OpenTelemetryNoRecordEventsSpanImplTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import io.opencensus.trace.Tracestate;
3939
import io.opentelemetry.api.common.AttributeKey;
4040
import io.opentelemetry.api.common.Attributes;
41+
import io.opentelemetry.api.common.Value;
4142
import java.util.HashMap;
4243
import java.util.Map;
4344
import java.util.Random;
@@ -93,6 +94,7 @@ public void doNotCrash() {
9394
noRecordEventsSpan.setAttribute("OTelAttributeKeyLong", 123);
9495
noRecordEventsSpan.setAttribute("OTelAttributeKeyDouble", 123.45);
9596
noRecordEventsSpan.setAttribute("OTelAttributeKeyBoolean", true);
97+
noRecordEventsSpan.setAttribute("OTelAttributeKeyValue", Value.empty());
9698
noRecordEventsSpan.addEvent("OTel event 1");
9799
noRecordEventsSpan.addEvent("OTel event 2", 29922310, TimeUnit.HOURS);
98100
noRecordEventsSpan.addEvent(

0 commit comments

Comments
 (0)