Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative to #6973, #6960, #6959, #6958.
In contrast to these other approaches, the key feature in this proposal is that we leave existing Attributes, AttributeKey, AttributeType alone. These represent the standard attributes and don't have any new situational surface area with the potential to confuse users.
Instead, this proposes we introduce new ExtendedAttribute, ExtendedAttributeKey, ExtendedAttributeType classes to represent the extended version of standard attribute used in log attributes.
The LogRecordBuilder API has overloads to accept either Attributes or ExtendedAttributes.
There are APIs for converting between Attribute / ExtendedAttribute where it makes sense:
semantic-convention-java
can be easily converted to the extended equivalentOn the SDK side, there's a new LogRecordData#getExtendedAttributes() method for exporters to access and encode extended attributes. For backwards compatibility, exporters can of course continue to access LogRecordData#getAttributes() which gets a filtered set of entries.
This is still a rough sketch, but it proves its possible to provide good API ergonomics for the extended attributes representation used in logs / events without leaking any details into the existing standard attributes representation.
My one problem with this is that ExtendedAttributes is more restricted that what the spec says about log record attributes, with supported types: STRING, BOOLEAN, LONG, DOUBLE, STRING_ARRAY, BOOLEAN_ARRAY, LONG_ARRAY, MAP, MAP_ARRAY. I don't feel comfortable introducing this new API without language from the spec that gives me confidence that this is sufficient (i.e. that we don't need to support something like heterogeneous arrays).
For API usage demosntration, see ExtendedAttributesTest
cc @trask