Граф коммитов

138 Коммитов

Автор SHA1 Сообщение Дата
Michael Demmer c5afc12130 add ResetAll to CountersWithSingleLabel
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-10-04 06:32:12 -07:00
Michael Demmer 8b73b9c13b add prometheus exporter support for FloatFunc
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-08-06 14:49:23 -07:00
Michael Demmer 67144fcdfc remove the unused StringMap stat type
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-07-27 06:11:50 -04:00
Michael Demmer 03472f56c1 remove the unused Float stat type
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-07-27 06:11:50 -04:00
Michael Demmer f29adf48da remove the unused JSONFunc stat type
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-07-26 15:27:53 -04:00
Michael Demmer 4648dedcff tweak log message as per PR suggestion
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-07-26 15:22:57 -04:00
Michael Demmer 86de973c7d change the unsupported metric type case to log.Fatalf
Also minor comment changes as suggested in PR feedback.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-07-26 15:22:57 -04:00
Michael Demmer 3bd111e0e9 silently ignore certain unsupported metric types
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>
2018-07-26 15:22:57 -04:00
Alain Jobart 902e3d0366 Moving stats variable escaping to its own file.
That way it can be customized.

Signed-off-by: Alain Jobart <alainjobart@google.com>
2018-07-11 15:24:29 -07:00
Michael Berlin a798f8f470
Merge pull request #4033 from dweitzman/fix_memory_leak
Fix a memory leak in opentsdb reporting
2018-06-18 10:06:01 -07:00
David Weitzman 6088a6f5c6 Fix a memory leak in opentsdb reporting
Responses from http.* methods must be explicitly closed.

Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-06-17 17:38:13 -07:00
David Weitzman b57b0647ba Replace "." with "_" in multi-counter and multi-timings label values.
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>
2018-06-11 16:11:37 -07:00
Sugu Sougoumarane baff2b6d9a
Merge pull request #3922 from dweitzman/opentsdb_backend
Basic support for -stats_backend opentsdb
2018-06-01 19:05:05 -07:00
David Weitzman 76e01b657a Basic support for -stats_backend opentsdb
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-06-01 11:13:00 -07:00
Michael Demmer 6b81f05657
Merge pull request #3965 from tinyspeck/topology-watcher-avoid-recheck
Topology watcher refreshKnownTablets option
2018-05-29 09:43:57 -07:00
Michael Demmer cab8f268d2 prometheus: fix the sum value to be in seconds
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>
2018-05-23 15:13:46 -07:00
Michael Demmer 67a94906ab add a counters.ZeroAll helper method for tests
Unlike ResetAll, ZeroAll keeps all the same keys in the map but
changes all the values to zero.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-05-20 21:41:06 -07:00
David Weitzman 05ac7222c0 Defend against a potential race condition in registering push stats providers.
Signed-off-by: David Weitzman <dweitzman@pinterest.com>
2018-05-04 14:47:24 -07:00
Michael Demmer 191021c6a0 clean up cutoffs intitialization
As suggested in PR review, move the intitialization of the cutoffs
before the struct creation.

Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-30 17:17:26 -07:00
Michael Demmer 213d4468aa remove the unused LabelName() from the Histogram
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-30 17:14:47 -07:00
Michael Demmer 86a27284eb use Label() instead of LabelName()
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>
2018-04-30 17:12:34 -07:00
Michael Demmer f86ede172f use "help" uniformly as suggested in PR review
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-30 17:10:42 -07:00
Michael Demmer fd7b5f84b2 use a singleton struct instead of a pointer
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-30 15:13:05 -07:00
Michael Demmer 507655b5cc reorganize all the collector instantiation functions
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>
2018-04-30 15:09:02 -07:00
Michael Demmer 066e88eabc add prometheus support for stats.NewHistogram
Signed-off-by: Michael Demmer <mdemmer@slack-corp.com>
2018-04-30 15:08:52 -07:00
Michael Demmer 504550ecef make the label name customizable for stats.NewTimings
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>
2018-04-30 15:08:34 -07:00
Michael Berlin a6c5e26478 stats: Remove CountersFunc type.
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>
2018-04-28 14:34:31 -07:00
Michael Berlin 2388a9b9f4 stats: Improve counter documentation.
Signed-off-by: Michael Berlin <mberlin@google.com>
2018-04-28 13:03:32 -07:00
Michael Berlin 66747a1ebb stats: Change order of "help" parameter in (Gauges|Counters)Func* types.
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>
2018-04-28 12:37:43 -07:00
Michael Berlin 8e9d69758d stats: CountersWithSingleLabel: Rename "labelName" to "label" to be more consistent with the *WithMultiLabels counterparts.
Signed-off-by: Michael Berlin <mberlin@google.com>
2018-04-28 12:14:51 -07:00
Michael Berlin a20b453db0 stats: Rename (Counters|Gauges)WithLabels to *WithSingleLabel.
The new name is more consistent with the *WithMultiLabels counterparts.

Signed-off-by: Michael Berlin <mberlin@google.com>
2018-04-28 11:59:40 -07:00
Michael Berlin 3b11bceedc stats: Reorder code in counters.go.
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>
2018-04-28 10:57:22 -07:00
Michael Berlin cd6afec776 stats: Split Duration* types into CounterDuration* and GaugeDuration*.
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>
2018-04-28 09:17:45 -07:00
Michael Berlin 56190fa3cc stats: Reorder calls in test to make them consistent with the other tests.
"gotname" and "gotv" type should always be checked first.

Signed-off-by: Michael Berlin <mberlin@google.com>
2018-04-28 08:57:55 -07:00
Michael Berlin fbe5eb4686 stats: Fix invalid format string in test.
Signed-off-by: Michael Berlin <mberlin@google.com>
2018-04-28 08:55:00 -07:00
Michael Berlin cac79493f2 stats: Simplify code for single-value stat variables.
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>
2018-04-27 17:37:33 -07:00
Michael Berlin a535c6b328 stats: Move Counter* and Gauge* types into new file counter.go.
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>
2018-04-27 16:04:56 -07:00
David Weitzman e6b1e31439 Factor out glog references for ease of dropping in an adapter to a different logging library.
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>
2018-04-20 19:40:15 -07:00
Michael Berlin 9a1fc3f5f2 stats: Add Counts() method to multi counter type.
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>
2018-04-20 17:16:48 -07:00
Maggie Zhou 8b2491a259 Add gotname & gotv tests to export_test.go
Don't export counters. Refactor prometheusbackend.go code to collect
CountersWithLabels and GaugesWithLabels explicitly instead of relying on
underlying unexported-now Counters.

Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
2018-04-20 16:51:46 -07:00
Maggie Zhou 42c8a2aeb9 Remove new line.
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
2018-04-20 16:51:46 -07:00
Maggie Zhou dbc98471d8 Initialize the throttledLogger before calling stats.Register()
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
2018-04-20 16:51:46 -07:00
Maggie Zhou b9c7d0c55c Use the throttled logger for unsupported metric types and decrementing
counters.

Remove some unneccessary commented out code.

Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
2018-04-20 16:51:46 -07:00
Maggie Zhou 629294d4ee Create new snake_case_converter.
Add a conversion function from - to _ and add unit test.
Signed-off-by: Maggie Zhou <mzhou@slack-corp.com>
2018-04-20 16:51:46 -07:00
Maggie Zhou 3fa5a10e4d Write a modification to kebab case converter for converting to snake
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>
2018-04-20 16:51:46 -07:00
Maggie Zhou 8ae888d83d - Changed up `CounterFunc` & `GaugeFunc` to take in a new type: `MetricFunc` that allows us to both export ints (like it did before) and now also durations.
- 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>
2018-04-20 16:51:46 -07:00
Maggie Zhou e1b31443cb Support DurationFunc
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>
2018-04-20 16:51:46 -07:00
Maggie Zhou 50e0d11406 Dedupe metric names with namespace names.
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>
2018-04-20 16:51:46 -07:00
Maggie Zhou f2afcd25d5 Get rid of the pull_backend.go
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>
2018-04-20 16:51:46 -07:00
Maggie Zhou 0d17a264e0 Quick followup to @demmer's IRL comments that I could push some of the
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>
2018-04-20 16:51:46 -07:00