diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-03-25 16:01:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-25 16:01:18 +0800 |
commit | 86989e3fcd93ac319dfbced226b3902520a5a4a9 (patch) | |
tree | 12cd70f812c25be27c9fd391190e3b09e8335322 /metrics | |
parent | e852505acedf6d3728330852b2d816ebf12a2cfb (diff) | |
download | go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.tar go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.tar.gz go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.tar.bz2 go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.tar.lz go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.tar.xz go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.tar.zst go-tangerine-86989e3fcd93ac319dfbced226b3902520a5a4a9.zip |
core: split out detailed trie access metrics from insertion time (#19316)
* core: split out detailed trie access metrics from insertion time
* cmd, core, metrics: support expensive optional metrics
Diffstat (limited to 'metrics')
-rw-r--r-- | metrics/metrics.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/metrics/metrics.go b/metrics/metrics.go index 5910fb073..6d14c8ecf 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -15,24 +15,41 @@ import ( ) // Enabled is checked by the constructor functions for all of the -// standard metrics. If it is true, the metric returned is a stub. +// standard metrics. If it is true, the metric returned is a stub. // // This global kill-switch helps quantify the observer effect and makes // for less cluttered pprof profiles. var Enabled = false -// MetricsEnabledFlag is the CLI flag name to use to enable metrics collections. -const MetricsEnabledFlag = "metrics" -const DashboardEnabledFlag = "dashboard" +// EnabledExpensive is a soft-flag meant for external packages to check if costly +// metrics gathering is allowed or not. The goal is to separate standard metrics +// for health monitoring and debug metrics that might impact runtime performance. +var EnabledExpensive = false + +// enablerFlags is the CLI flag names to use to enable metrics collections. +var enablerFlags = []string{"metrics", "dashboard"} + +// expensiveEnablerFlags is the CLI flag names to use to enable metrics collections. +var expensiveEnablerFlags = []string{"metrics.expensive"} // Init enables or disables the metrics system. Since we need this to run before // any other code gets to create meters and timers, we'll actually do an ugly hack // and peek into the command line args for the metrics flag. func init() { for _, arg := range os.Args { - if flag := strings.TrimLeft(arg, "-"); flag == MetricsEnabledFlag || flag == DashboardEnabledFlag { - log.Info("Enabling metrics collection") - Enabled = true + flag := strings.TrimLeft(arg, "-") + + for _, enabler := range enablerFlags { + if !Enabled && flag == enabler { + log.Info("Enabling metrics collection") + Enabled = true + } + } + for _, enabler := range expensiveEnablerFlags { + if !Enabled && flag == enabler { + log.Info("Enabling expensive metrics collection") + EnabledExpensive = true + } } } } |