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

Histogram bucket helpers #177

Merged

Conversation

lawrencejones
Copy link
Contributor

Most client libraries provide helpers for generating linear/exponential
histogram buckets. This provides the same interface as the golang
client.

@lawrencejones lawrencejones force-pushed the lawrence-add-histogram-helpers branch from 9fdbdaf to d872743 Compare January 14, 2020 09:50
@lawrencejones
Copy link
Contributor Author

FYI @dmagliola

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling d872743 on lawrencejones:lawrence-add-histogram-helpers into 260e51a on prometheus:master.

@coveralls
Copy link

coveralls commented Jan 14, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 844e451 on lawrencejones:lawrence-add-histogram-helpers into 2f91bbd on prometheus:master.

@lawrencejones
Copy link
Contributor Author

Any love @Sinjo?


def self.exponential_buckets(start:, factor: 2, count:)
count.times.map { |idx| start.to_f * factor ** idx }
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I love this feature, it was actually on our TO-DO list, so glad you tackled it.
I'm not sure about the location of these two methods, though...

Could you move these to be static methods in the Histogram class?

Also, should we validate the parameters, like the Go client does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps validating is an idea? Will have a look at that.

On the class method part, is it worth moving them there? Bearing in mind that would be different from the other clients.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's worth moving.
That's where I would look for them as a user of this library.
And unless I misread the Go code, that's where they are in the Go client too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I did misread the Go code. I saw it in Histogram.go and assumed it'd be there.
I think the conventions in these two languages are different.
Whereas you do NewHistogram in Go, you go Histogram.new in Ruby. Everything Histogram related is in the Histogram class itself.
The Client class is only used once for setup on startup, or not at all. It doesn't look like a place where someone would look when creating a histogram.

On that note, though... Could we also add a little section in the README documenting these two methods? :D

Copy link
Member

@Sinjo Sinjo Feb 7, 2020

Choose a reason for hiding this comment

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

Having them on Histogram would definitely match my expectations when writing Ruby. I think going with typical idiom within the language is a very fair shout. In client_java they're chainable methods on the Histogram builder.

@Sinjo
Copy link
Member

Sinjo commented Jan 28, 2020

Guess who forgot to specifically set up notifications for all activity on this project 🤦🏻‍♂️

Didn't realise when we were working super actively on 1.0 and only thought to go looking after you tagged me! Gonna look over this now.

Most client libraries provide helpers for generating linear/exponential
histogram buckets. This provides the same interface as the golang
client.

Signed-off-by: Lawrence Jones <lawrjone@gmail.com>
@dmagliola dmagliola force-pushed the lawrence-add-histogram-helpers branch from d872743 to 844e451 Compare February 25, 2020 17:35
@dmagliola dmagliola requested a review from Sinjo February 25, 2020 17:36
@dmagliola
Copy link
Collaborator

Ok, i've made the changes I mentioned above (moving the helper methods to the Histogram class, and added a mention of the feature in the README.
@Sinjo can you take a look?

@Sinjo Sinjo merged commit acd1466 into prometheus:master Mar 2, 2020
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.

4 participants