-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid using Attribute
in common pdata components related to AnyValue proto field
#4988
Comments
Another option that I can think of:
Different idea: |
@bogdandrutu we will have the following types then, right?
It looks good to me, I don't think we can anticipate any conflicts in future. Not sure the generic function |
+1 on the type part. For the generics, I would like to look how will that will be, not 100% sure about all the generics tricks. We can discuss that separately. |
Once #5001 is merge we will get the following types: AnyValue wrappers:
AnyValue collection wrappers :
So we will have Not sure if we need to rename @bogdandrutu let me know WDYT |
Should we |
Yes, I think renaming The only concern is that |
Do we have a constant defined for that string that is typically used? If so and we update it simultaneously that might not be so bad, but if not we should look at what other options we have. Is it the case that the |
Yes it is. Result of |
Maybe change the value in the const ValueTypeArray = ValueTypeSlice They're semantically identical and shouldn't have different values, I don't think. |
Good idea. Thanks! |
The initial problem stated in this ticket is resolved now. I created another follow-up issue for the |
Problems
All of the pdata wrappers related to AnyValue fields include
Attribute
part in its name because the field used to be applicable to theattributes
fields only, like here. But it's not the case anymore sincepdata.LogRecord.Body
uses AnyValue wrapped bypdata.AttributeValue
. This is the main goal that intended to be addressed in #4818.But the are couple of other naming issues related to this problem that need to be addressed:
1. AttributeMap naming
pdata.AttributeMap
struct is a wrapper around repeated KeyValue proto field. The name seems reasonable when it's used for attributes like here. But it also can be used as an instance of AnyValue. For example the following line currently returns a value ofAttributeMap
type while there is nothing related to attribute in the call:2. AttributeValueSlice naming
There are couple of problem with this name:
AttributeValue...
types likeAttributeValueString
,AttributeValueInt
,AttributeValueMap
,AttributeValueArray
, etc. They both have the same naming schema but different meaning:AttributeValue<type>
is a wrapper ofAnyValue
with a particular<type>
.AttributeValueSlice
is a slice ofAnyValue
wrappers.It's especially confusing to have both
AttributeValueArray
andAttributeValueSlice
.AttributeValueSlice
(wrapper over an array of AnyValue fields) is similar toAttributesMap
(wrapper over a key-value collection of AnyValue). Therefore they should have similar naming. This is why the both of the problems described in this issue should be considered together.Possible solutions
We cannot follow the approach proposed in #4818 and rename
AttributeValueSlice
toAnyValueSlice
. It would require renamingAttributeMap
toAnyValueMap
which will conflict with existingAnyValueMap
(wrapper ofAnyValue
with KeyValueList type).Therefore we need to define some consistent naming for
AttributeMap
andAttributeValueSlice
that is different from what is proposed in #4818. There are two possible options:1. Use AnyValue prefix for pdata.AttributeValueSlice and pdata.AttributeMap
Use
AnyValue
prefix forpdata.AttributeValueSlice
andpdata.AttributeMap
instead of using it forAttributeValue<type>
. It means that another naming schema has to be found forAttributeValue<type>
that is currently proposed to be renamed asAnyValue<type>
in #4818 to avoid collisions.pdata.AttributeValueSlice
becomespdata.AnyValueSlice
: slice of AnyValue wrappers.pdata.AttributeMap
becomespdata.AnyValueMap
: map of AnyValue wrappers.2. Drop Attribute part in pdata.AttributeValueSlice and pdata.AttributeMap
pdata.AttributeValueSlice
andpdata.AttributeMap
can be renamed topdata.Slice
andpdata.Map
. This approach seems to be working well.pdata.Slice
andpdata.Map
should be descriptive enough.The only concern with this approach is that
pdata.NewAttributeMapFromMap
function becomespdata.NewMapFromMap
after straight-forward renaming. We probably need another name for this function. Maybepdata.NewMapFromRawMap
.3. Use Slice and KeyValueSlice names instead of AttributeValueSlice and AttributeMap
pdata.KeyValueSlice
name may seem not ideal, but it represents its internals and works well with all other names.pdata.NewAttributeMapFromMap
function becomespdata.NewKeyValueSliceFromMap
then.Any other ideas are very welcome.
The text was updated successfully, but these errors were encountered: