Skip to content
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

Make it more efficient and compatible to use SampleHistogram #439

Merged
merged 5 commits into from
Jan 26, 2023

Conversation

krajorama
Copy link
Member

Store SampleHistogram in SampleHistogramPair as pointer.
More compatible with what protobuf generates.
More efficient when taking the histogram from the pair.
Simpler test code.

Signed-off-by: György Krajcsovits [email protected]

Store SampleHistogram in SampleHistogramPair as pointer.
More compatible with what protobuf generates.
More efficient when taking the histogram from the pair.
Simpler test code.

Signed-off-by: György Krajcsovits <[email protected]>
@@ -135,7 +135,7 @@ func (s *SampleHistogram) Equal(o *SampleHistogram) bool {

type SampleHistogramPair struct {
Timestamp Time
Histogram SampleHistogram
Histogram *SampleHistogram
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth commenting that it should never be nil and it is as a pointer for efficiency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should MarshalJSON check that it's nil and error out if it is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've ended up convincing myself to error on nil histogram, to avoid ever generating invalid JSON from this

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: György Krajcsovits <[email protected]>
model/value_histogram.go Outdated Show resolved Hide resolved
Co-authored-by: Ganesh Vernekar <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>
@codesome codesome merged commit ca1f99b into prometheus:main Jan 26, 2023
radek-ryckowski pushed a commit to goldmansachs/common that referenced this pull request May 18, 2023
…eus#439)

Store SampleHistogram in SampleHistogramPair as pointer.
More compatible with what protobuf generates.
More efficient when taking the histogram from the pair.
Simpler test code.

Signed-off-by: György Krajcsovits <[email protected]>
Signed-off-by: George Krajcsovits <[email protected]>
Co-authored-by: Ganesh Vernekar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants