Skip to content

Make it more efficient and compatible to use SampleHistogram#439

Merged
codesome merged 5 commits intoprometheus:mainfrom
krajorama:samplehistogrampair-use-pointer
Jan 26, 2023
Merged

Make it more efficient and compatible to use SampleHistogram#439
codesome merged 5 commits intoprometheus:mainfrom
krajorama:samplehistogrampair-use-pointer

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 gyorgy.krajcsovits@grafana.com

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 <gyorgy.krajcsovits@grafana.com>
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 <gyorgy.krajcsovits@grafana.com>
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
@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 <gyorgy.krajcsovits@grafana.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
radek-ryckowski pushed a commit to goldmansachs/common that referenced this pull request May 21, 2025
…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 <gyorgy.krajcsovits@grafana.com>
Signed-off-by: George Krajcsovits <krajorama@users.noreply.github.com>
Co-authored-by: Ganesh Vernekar <ganeshvern@gmail.com>
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