Skip to content

Empty string attributes and OTLP #4660

@breedx-splk

Description

@breedx-splk

There appears to be a disconnect in how the spec wording and protobuf definitions treat empty string values in attributes.

Per the spec, these empty string Attribute values are important:

Attribute values expressing a numerical value of zero, an empty string, or an empty array are considered meaningful and MUST be stored and passed on to processors / exporters.

This strongly suggests that empty string attribute values should be serialized as strings of zero length, and not simply as an "empty" Attribute.

The .proto definition, on the other hand, suggests something else within AnyValue (of which string is a type):

// The value is one of the listed fields. It is valid for all values to be unspecified
// in which case this AnyValue is considered to be "empty".

Because of this, many (all?) implementations do not specify a value at all when serializing an empty string, because it is assumed to be empty.

⭐ The problem, then, is that the Attribute's type information is lost.

A consumer cannot differentiate between an empty string and other empty types (array, list, object).

This issue was uncovered when attempting to deserialize protobuf data that contained empty string attribute values (from java contrib disk buffering code, linked below).

It can also be shown with json, in that the "empty" case omits the stringValue value, like this:

{
  "key": "empty",
  "value": {} // no type information!
}

instead of

{
  "key": "empty",
  "value": {
    "stringValue": "" // clearly a string
  }
}

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage:deciding:community-feedbackOpen to community discussion. If the community can provide sufficient reasoning, it may be accepted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions