Instead of logging a warning for the stats types which are known
to be incompatible with prometheus (e.g. String, Rates, etc), just
silently skip them in the publish phase.
At the same time remove the throttled logger and replace with a
warning log in case new metric types are created which aren't
covered as part of the backend.
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
This ensures that the number of labels at parse time equals the number of labels at join time.
Without this, some metrics exporters can get confused and panic().
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
When exporting timings to prometheus, convert the `_sum` value from
nanoseconds to seconds as part of the export.
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
As suggested in PR review this brings Timings in line with the
naming used by the various Counter types.
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Move the various newXYZ functions from prometheusbackend.go into
collectors.go so that the constructor function lives alongside the
struct definition itself.
As part of this rename the various functions so the constructor
function name matches the struct name.
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Instead of hard-coding the label "Histograms" inside the prometheus
exporter, change the stats.NewTimings API to be more like the other
labelled metrics in which the label name is part of the constructor.
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
Instead, all code should use "CountersFuncWithMultiLabels" with a single label instead.
There was only one place in the codebase (binlog_players.go) which had to be changed.
Signed-off-by: Michael Berlin <mberlin@google.com>
Now the function signatures are consistent with all other constructors.
Other changes:
- Do not repeat the type in function signatures when it's the same.
- Do not use receiver names with more than 2 letters.
- Do not use pointer receiver if you don't want to modify the object.
Signed-off-by: Michael Berlin <mberlin@google.com>
It should read as follows now:
- counters - single label
- counters - single label (function)
- counters - multiple labels
- counters - multiple labels (function)
and then the same thing for gauges as well.
This commit did not change any functionality.
Signed-off-by: Michael Berlin <mberlin@google.com>
So far, the pool wait time is the only metric in our code base which requires a counter duration.
All other metrics are just exposures of a duration configuration parameter.
Signed-off-by: Michael Berlin <mberlin@google.com>
https://github.com/vitessio/vitess/pull/3784 introduced two layers of code for "stats.Counter" (and the new type "stats.Gauge").
As a consequence, it was for example possible to create a "stats.Gauge" for a time.Duration value.
This approach did not work well with our internal usage of the stats package.
Therefore, I reversed this and simplified the code:
- MetricFunc() interface was removed. Instead, a CountFunc or a GaugeFunc requires a simple func() int64 as input.
- IntFunc() removed. Before https://github.com/vitessio/vitess/pull/3784, it was used to implement the expvar.Var interface. But now, this is taken care of by the types itself e.g "stats.CounterFunc". Therefore, we do not need it anymore and users of the "stats" package can just pass a plain func() int64.
- Added types "Duration" and "DurationFunc" back.
- Added "Variable" interface. This allowed to simplify the Prometheus code which depends on the Help() method for each stats variable.
- Prometheus: Conversion to float64 values is now done in prometheusbackend.go and removed from the stats package.
BUG=78571948
Signed-off-by: Michael Berlin <mberlin@google.com>
Move Duration* types into duration.go.
This is a mere move of code and no change in functionality.
By splitting out the code, I hope it will be easier to maintain it.
Signed-off-by: Michael Berlin <mberlin@google.com>
Note: This is the revert of a temporary revert and has the same effect
as the original PR: https://github.com/vitessio/vitess/pull/3830
Revert "Revert "Factor out glog references""
This reverts commit 246e2898d2.
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
An existing test used this functionality. When we stopped exporting the
"counters" type, the test lost that functionality. Instead of relying on
an implementation detail, there is a proper public method now.
Signed-off-by: Michael Berlin <mberlin@google.com>
case.
Log an warning when we call Add() on a counter with a negative number.
Fix the double underscore in the prometheus exported metrics when we
dedupe the namespace.
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
- Moved Prom specific stuff in the plugins to the prometheus backend
itself.
- A ton of stats help string fix ups.
- some counters are gauges, and some gauges are counters! Fix those.
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
Convert Nanoseconds to seconds
Call Init (handler) inside servenv.OnRun()
Add unit tests.
For counter, it doesn't make sense to have a function called ResetAll
and not one called Reset so re-rename that.
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
Add plugins for each of the components.
Rename prombackend => prometheusbackend
Rename publishPromMetric to publishPrometheusMetric
Rename Reset() => ResetAll()
ResetCounter => Reset()
Rename various Counters => Gauges per Mike's helpful pointers.
Rename a few help strings.
Remove the comments in go/vt/worker/worker.go metrics and move them 100% into help functions.
Add a GaugeFuncWithMultiLabels
Add a CounterFunc
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
Fix tests to use the new metric names.
Fix tests that expected gauges and not counters. (more to come on this
thing, but these were the tests that indicated gauges early)
Fix the `Set()` implementation for GaugesWithMultiLabels.
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
pull_backend.go stuff into prombackend/prombackend.go's Register call
and make the pull_backend.go an interface only.
Also, fix some more types from the gigantic refactor, and run
GoLint/GoVet
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>