Skip to content

Commit c2c62aa

Browse files
Empty attribute values in disk buffering (#2268)
Co-authored-by: otelbot <[email protected]>
1 parent 28d8f21 commit c2c62aa

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

disk-buffering/src/main/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/common/AttributesMapper.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ private static void addValue(AttributesBuilder builder, String key, AnyValue val
8585
} else if (value.array_value != null) {
8686
addArray(builder, key, value.array_value);
8787
} else {
88-
throw new UnsupportedOperationException();
88+
// Until we have complex attribute types that could potentially yield
89+
// empty objects, we MUST assume here that the writer put an empty string
90+
// into the value of the attribute. This will need to change later, when complex
91+
// types arrive and the spec issue is resolved.
92+
//
93+
// See spec issue: https://github.com/open-telemetry/opentelemetry-specification/issues/4660
94+
builder.put(AttributeKey.stringKey(key), "");
8995
}
9096
}
9197

disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/internal/serialization/mapping/common/AttributesMapperTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ void verifyMapping() {
2121
Attributes attributes =
2222
Attributes.builder()
2323
.put(AttributeKey.stringKey("someString"), "someValue")
24+
.put(AttributeKey.stringKey("emptyString"), "")
2425
.put(AttributeKey.booleanKey("someBool"), true)
2526
.put(AttributeKey.longKey("someLong"), 10L)
2627
.put(AttributeKey.doubleKey("someDouble"), 10.0)

disk-buffering/src/test/java/io/opentelemetry/contrib/disk/buffering/testutils/TestData.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public final class TestData {
3737
.put("conditions", false, true)
3838
.put("scores", 0L, 1L)
3939
.put("coins", 0.01, 0.05, 0.1)
40+
.put("empty", "")
41+
.put("blank", " ")
4042
.build();
4143

4244
public static final Resource RESOURCE_FULL =

0 commit comments

Comments
 (0)