Empty attribute values in disk buffering (#2268)

Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
This commit is contained in:
jason plumb 2025-09-18 13:18:37 -07:00 committed by GitHub
parent 28d8f21568
commit c2c62aa973
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -85,7 +85,13 @@ public final class AttributesMapper {
} else if (value.array_value != null) {
addArray(builder, key, value.array_value);
} else {
throw new UnsupportedOperationException();
// Until we have complex attribute types that could potentially yield
// empty objects, we MUST assume here that the writer put an empty string
// into the value of the attribute. This will need to change later, when complex
// types arrive and the spec issue is resolved.
//
// See spec issue: https://github.com/open-telemetry/opentelemetry-specification/issues/4660
builder.put(AttributeKey.stringKey(key), "");
}
}

View File

@ -21,6 +21,7 @@ class AttributesMapperTest {
Attributes attributes =
Attributes.builder()
.put(AttributeKey.stringKey("someString"), "someValue")
.put(AttributeKey.stringKey("emptyString"), "")
.put(AttributeKey.booleanKey("someBool"), true)
.put(AttributeKey.longKey("someLong"), 10L)
.put(AttributeKey.doubleKey("someDouble"), 10.0)

View File

@ -37,6 +37,8 @@ public final class TestData {
.put("conditions", false, true)
.put("scores", 0L, 1L)
.put("coins", 0.01, 0.05, 0.1)
.put("empty", "")
.put("blank", " ")
.build();
public static final Resource RESOURCE_FULL =