-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[PRW 2.0] (part3) Moved type specific conversions to prompb and writev2 codecs. #14347
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
Conversation
bcc3595
to
97ffc66
Compare
f8f8535
to
c5faeb9
Compare
523097b
to
b244424
Compare
@@ -915,57 +621,6 @@ func LabelProtosToMetric(labelPairs []*prompb.Label) model.Metric { | |||
return metric | |||
} | |||
|
|||
// LabelProtosToLabels transforms prompb labels into labels. The labels builder | |||
// will be used to build the returned labels. | |||
func LabelProtosToLabels(b *labels.ScratchBuilder, labelPairs []prompb.Label) labels.Labels { |
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 affects #14316 cc @pracucci in some way, by removing this helper from this file.
We moved those methods, and they are accessible via prompb.FromLabels
and prompb.TimeSeries.ToLabels
. I think it makes things much cleaner and should work for downstream projects. Do you mind double checking if you are happy with this Marco? 🤗 (this PR is against remote-write-2.0 but we will merge this branch to main next week likely)
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.
Thanks for the ping Bartek. I'm good with this change, thanks.
// NOTE(bwplotka): This file's code is tested in /prompb/rwcommon. | ||
|
||
// ToLabels return model labels.Labels from timeseries' remote labels. | ||
func (m TimeSeries) ToLabels(b *labels.ScratchBuilder, _ []string) labels.Labels { |
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.
FYI @beorn7 @krajorama we cleaned up histogram conversions as it's gets tricky (duplicated) with another proto struct. Would you be happy with flow like this (see PR description).
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 guess @krajorama is way deeper into practical considerations here than I, so he should make the call.
/prombench main |
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.
Makes sense, I like how the naming is cleaner. We should probably follow the same in Mimir.
I've added some nits. Also there's already some generator functions in tsdb/tsdbutil/histogram.go for generating test histograms, but using your own is fine as well
storage/remote/codec_test.go
Outdated
req.Timeseries[i].Histograms[j].PositiveDeltas = h.PositiveDeltas | ||
req.Timeseries[i].Histograms[j].PositiveCounts = h.PositiveCounts | ||
req.Timeseries[i].Histograms[j].ResetHint = prompb.Histogram_ResetHint(h.ResetHint) | ||
req.Timeseries[i].Histograms[j].Timestamp = h.Timestamp |
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.
Let's add a panic() if this is called on a histogram with custome_values filled in. Just to be on the safe side.
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.
Good point. Let's add TODOs to conversion code. For this conversion (I simplified it here), it;s only used in tests so we know it's not custom. Let's fix NHCB cases once on main branch?
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.
It's on main branch now (:
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 in 49ab109
/prombench cancel |
Benchmark cancel is in progress. |
b244424
to
8a6ce53
Compare
…v2 codecs. Signed-off-by: bwplotka <bwplotka@gmail.com>
8a6ce53
to
0dd176b
Compare
This attempts to improve readability and consistency of our rw code & tests. For example to make sure conversions from/to model types are well tested.
We can't use generics easily due to details mentioned in Slack and old attempt so I propose we take it slowly and for now clean conversion code by:
prompb/rwcommon
for shared proto logic. For now I propose we test the above conversions in one place. The reason is that while having impl hidden in each version is beneficial, hiding tests is bit worse - it can be non-obvious when tests drifts for those. Thisrwcommon
pkg can be also later used for more stuff e.g. shared types or interfaces/generics.NOTE: For fun I shared one alternative here with generics. I think it's ... bit too much for 2 types, but maybe those generic interfaces would help further on with buildWriteRequest stuff. For just testing, it's too much and complex.