-
Notifications
You must be signed in to change notification settings - Fork 193
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
add histogram #1145
add histogram #1145
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
the Add() method now takes a metricType argument, but I'm wondering if we should move to AddXXX similar to how there's AddHistogram.
seems a bit neater as an API
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.
Looks great! I'd prefer we don't add Gauge/Count/Summary just yet, as we're not doing anything with them and there's risk that they'll need to change.
Tests are failing because of my use of |
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.
Looks good overall, just a few small things.
Tests are failing because of my use of math.Round, which was introduced in go1.10. Do we still want/need to support versions this old? go1.9 was released in august 2017.
I don't want to, but yes we need to until we release a v2 of the agent.
There's an internal package with a round implementation for older versions of Go: https://github.com/elastic/apm-agent-go/tree/master/internal/apmmath
shim for <go1.10, when math.Round was introduced
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.
Code looks in good shape, seems to be an issue with the value for the last bucket.
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.
perfect!
module/apmprometheus/gatherer.go
Outdated
// we need to modify the current final bucket, | ||
// and add an additional bucket with these | ||
// observations. | ||
if infBucketCount := totalCount - bucketCount; infBucketCount > 0 { |
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.
Is it worth adding a valuesLen > 0
check to this? I don't see why anyone would do that, but we probably shouldn't panic if they do.
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 don't think that can happen, since you can't create a histogram with 0 buckets, but it doesn't hurt to check
https://github.com/prometheus/client_golang/blob/master/prometheus/histogram.go#L221-L223
WIP for adding histogram support for prometheus.
The change to
Metric
is very much "make it work". I'd prefer to either add some sort of metric type identifier within theMetric
type and some way to enforce validity within the type (Buckets
andCounts
should both be set and the correct length,Value
shouldn't be set at the same time asBuckets
andCounts
), or some sort of metric type interface.Example sample: