Skip to content

Commit bfacd62

Browse files
committed
Add test
1 parent 6e1c6e7 commit bfacd62

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

exporters/otlp/common/src/testIncubating/java/io/opentelemetry/exporter/internal/otlp/logs/LogsRequestMarshalerIncubatingTest.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import com.google.protobuf.Message;
1414
import com.google.protobuf.util.JsonFormat;
1515
import io.opentelemetry.api.common.Attributes;
16+
import io.opentelemetry.api.common.Value;
17+
import io.opentelemetry.api.incubator.common.ExtendedAttributeKey;
1618
import io.opentelemetry.api.incubator.common.ExtendedAttributes;
1719
import io.opentelemetry.api.internal.OtelEncodingUtils;
1820
import io.opentelemetry.api.logs.Severity;
@@ -74,6 +76,7 @@ void toProtoLogRecord_NotExtendedLogRecordData_DoesNotThrow(MarshalerSource mars
7476

7577
@ParameterizedTest
7678
@EnumSource(MarshalerSource.class)
79+
@SuppressWarnings("deprecation") // Testing deprecated EXTENDED_ATTRIBUTES until removed
7780
void toProtoLogRecord(MarshalerSource marshalerSource) {
7881
LogRecord logRecord =
7982
parse(
@@ -90,7 +93,7 @@ void toProtoLogRecord(MarshalerSource marshalerSource) {
9093
.setSpanContext(
9194
SpanContext.create(
9295
TRACE_ID, SPAN_ID, TraceFlags.getDefault(), TraceState.getDefault()))
93-
.setTotalAttributeCount(10)
96+
.setTotalAttributeCount(11)
9497
.setTimestamp(12345, TimeUnit.NANOSECONDS)
9598
.setObservedTimestamp(6789, TimeUnit.NANOSECONDS)
9699
// Extended fields
@@ -118,6 +121,21 @@ void toProtoLogRecord(MarshalerSource marshalerSource) {
118121
.build())
119122
.put("str_key", "str_value")
120123
.build())
124+
.put(
125+
ExtendedAttributeKey.valueKey("value_key"),
126+
Value.of(
127+
io.opentelemetry.api.common.KeyValue.of(
128+
"bool_key", Value.of(true)),
129+
io.opentelemetry.api.common.KeyValue.of(
130+
"double_key", Value.of(1.1)),
131+
io.opentelemetry.api.common.KeyValue.of("int_key", Value.of(1)),
132+
io.opentelemetry.api.common.KeyValue.of(
133+
"kv_list_key",
134+
Value.of(
135+
io.opentelemetry.api.common.KeyValue.of(
136+
"str_key", Value.of("str_value")))),
137+
io.opentelemetry.api.common.KeyValue.of(
138+
"str_key", Value.of("str_value"))))
121139
.build())
122140
.build()));
123141

@@ -144,6 +162,27 @@ void toProtoLogRecord(MarshalerSource marshalerSource) {
144162
keyValue("int_arr_key", anyValue(Arrays.asList(anyValue(1), anyValue(2)))),
145163
keyValue(
146164
"kv_list_key",
165+
AnyValue.newBuilder()
166+
.setKvlistValue(
167+
KeyValueList.newBuilder()
168+
.addValues(keyValue("bool_key", anyValue(true)))
169+
.addValues(keyValue("double_key", anyValue(1.1)))
170+
.addValues(keyValue("int_key", anyValue(1)))
171+
.addValues(
172+
keyValue(
173+
"kv_list_key",
174+
AnyValue.newBuilder()
175+
.setKvlistValue(
176+
KeyValueList.newBuilder()
177+
.addValues(
178+
keyValue("str_key", anyValue("str_value")))
179+
.build())
180+
.build()))
181+
.addValues(keyValue("str_key", anyValue("str_value")))
182+
.build())
183+
.build()),
184+
keyValue(
185+
"value_key",
147186
AnyValue.newBuilder()
148187
.setKvlistValue(
149188
KeyValueList.newBuilder()

0 commit comments

Comments
 (0)