-
Notifications
You must be signed in to change notification settings - Fork 524
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
Init histogram counters with 0 #4140
Conversation
585aa44
to
5b2e5a1
Compare
// If we are about to call Append for the first time on a series, | ||
// we need to first insert a 0 value to allow Prometheus to start from a non-null value. | ||
if s.isNew() { | ||
lb.Set(labels.MetricName, h.nameCount) |
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.
Question, maybe it makes sense to create a new ìnit` method in the interface:
type metric interface {
name() string
initMetrics(appender storage.Appender,...)
collectMetrics(appender storage.Appender, timeMs int64, externalLabels map[string]string) (activeSeries int, err error)
removeStaleSeries(staleTimeMs int64)
}
since I see we do the same logic in the counter
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 logic is actually of the series, not the metric. It needs passing a couple of values, the function would actually encapsulate very little. I don't think it's worth the hassle.
func (co *counterSeries) init(appender storage.Appender, lbls labels.Labels, ts int64) {
_, _ = appender.Append(0, lbls, ts, 0)
co.registerSeenSeries()
}
7f5d504
to
1b672e0
Compare
What this PR does:
Pushes a 0 to classic histogram's counter when the series is new to allow Prometheus to start from a non-null value.
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]