Skip to content

Commit b81a3d2

Browse files
committed
add empty array, empty map, and empty bytes
1 parent 532cd94 commit b81a3d2

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

exporters/otlp/common/src/test/java/io/opentelemetry/exporter/internal/otlp/traces/TraceRequestMarshalerTest.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ void toProtoSpan(MarshalerSource marshalerSource) {
161161
.put("false_value", false)
162162
.put("zero_int", 0L)
163163
.put("zero_double", 0.0)
164-
// TODO: add empty array, empty map, empty bytes, and true empty value
165-
// after https://github.com/open-telemetry/opentelemetry-java/pull/7973
164+
.put("empty_array", Value.of(Collections.emptyList()))
165+
.put("empty_map", Value.of(Collections.emptyMap()))
166+
.put("empty_bytes", Value.of(new byte[] {}))
166167
.build())
167-
.setTotalAttributeCount(17)
168+
.setTotalAttributeCount(20)
168169
.setEvents(
169170
Collections.singletonList(
170171
EventData.create(12347, "my_event", Attributes.empty())))
@@ -297,6 +298,27 @@ void toProtoSpan(MarshalerSource marshalerSource) {
297298
KeyValue.newBuilder()
298299
.setKey("zero_double")
299300
.setValue(AnyValue.newBuilder().setDoubleValue(0.0).build())
301+
.build(),
302+
KeyValue.newBuilder()
303+
.setKey("empty_array")
304+
.setValue(
305+
AnyValue.newBuilder()
306+
.setArrayValue(ArrayValue.newBuilder().build())
307+
.build())
308+
.build(),
309+
KeyValue.newBuilder()
310+
.setKey("empty_map")
311+
.setValue(
312+
AnyValue.newBuilder()
313+
.setKvlistValue(KeyValueList.newBuilder().build())
314+
.build())
315+
.build(),
316+
KeyValue.newBuilder()
317+
.setKey("empty_bytes")
318+
.setValue(
319+
AnyValue.newBuilder()
320+
.setBytesValue(ByteString.copyFrom(new byte[] {}))
321+
.build())
300322
.build());
301323
assertThat(protoSpan.getDroppedAttributesCount()).isEqualTo(1);
302324
assertThat(protoSpan.getEventsList())

0 commit comments

Comments
 (0)