-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New api/label
package, common label set impl
#651
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. Maybe some general problems:
- other SDK's will be forced to use api's way of generating a unique representation of a label set
- creating resources with duplicates used to use the first-wins mechanics, now it's last-wins.
- we probably could drop label encoder use in more places and limit that to exporters only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will address all of @krnowak's feedback later today. Please register your objections, if you have any! Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks like an improvement. The only things I see appear minor. The biggest thing seems to be the Resource
changes. The change of Attributes
-> Labels
needs to be updated project wide and a Merge
method added. Otherwise, this looks close to done.
PTAL. Note that this includes as a prerequisite the changes from #654 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome, thanks for the hard work!
All these review comments are minor or plain nits. They can be addressed at a later time if you want to ignore them.
(I added more tests.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great!
But I see that you have left the resource mostly as is, including the api dependency on sdk resource. I suppose this is something to be cleaned up in a future PR then.
What I found are mostly documentation issues, thus I'm going to approve the PR, so you can merge the PR right after fixing those.
api/label/set_test.go
Outdated
// No other String values are equal to this. | ||
for _, distinct := range s2d { | ||
if distinct[0] == d { | ||
continue | ||
} | ||
for _, otherDistinct := range distinct { | ||
require.NotEqual(t, otherDistinct, d) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same confusion here, but with strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This extracts the
sdk/metric
label set implementation, thesdk/export/metric
default label encoder, and moves them intoapi/label
. The new type is*label.Set
supports the same iterator interface, but with the removal of two interfacesLabels
andLabelStorage
are no longer needed, since the API uses structs and pointers.The main support implemented by the SDK's label set was computing a distinct value for every unique set of labels, after de-duplication and last-value-wins semantics are applied. The internal map key used in the SDK is now exposed as
label.Distinct
, which is a struct wrapping a non-exportedinterface{}
, wrapping a variable-size array.This replaces partly replaces #640 and #641, in that it changes how uniqueness is exposed and resources are represented.
Note that the new
label.Set
type replaces both the metric label set and the resource struct in this PR. In a future PR it should also replace thecorrelation.Map
(TODO).The
label.Set
object manages a cache of encodings by label encoder. This support is expanded to >1 encoding per label set, so that multiple exporters can co-exist without harming performance. The number of encodings is limited to 3 in this PR, but can be expanded in the future.