diff options
author | Valery Piashchynski <[email protected]> | 2021-01-21 13:25:36 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-01-21 13:25:36 +0300 |
commit | 7da6c78449776e1f3c6716250bca0b712a0423a4 (patch) | |
tree | f3512de66aca2bba408485a0ea2fc936c0e4fb9b /plugins/metrics | |
parent | 0ff05b2732b4fd0783f959c94c54d7e39169f979 (diff) |
Uniform all configs
Add debug server
Check nil's for all plugin intialization
Diffstat (limited to 'plugins/metrics')
-rw-r--r-- | plugins/metrics/config.go | 4 | ||||
-rw-r--r-- | plugins/metrics/plugin.go | 7 |
2 files changed, 8 insertions, 3 deletions
diff --git a/plugins/metrics/config.go b/plugins/metrics/config.go index 9459bc9b..dd36005e 100644 --- a/plugins/metrics/config.go +++ b/plugins/metrics/config.go @@ -134,5 +134,7 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) { } func (c *Config) InitDefaults() { - + if c.Address == "" { + c.Address = "localhost:2112" + } } diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 5ed1054e..859f3d24 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -30,7 +30,7 @@ type statsProvider struct { // Plugin to manage application metrics using Prometheus. type Plugin struct { - cfg Config + cfg *Config log logger.Logger mu sync.Mutex // all receivers are pointers http *http.Server @@ -41,12 +41,15 @@ type Plugin struct { // Init service. func (m *Plugin) Init(cfg config.Configurer, log logger.Logger) error { const op = errors.Op("metrics_plugin_init") + if !cfg.Has(PluginName) { + return errors.E(op, errors.Disabled) + } + err := cfg.UnmarshalKey(PluginName, &m.cfg) if err != nil { return errors.E(op, errors.Disabled, err) } - // TODO figure out what is Init m.cfg.InitDefaults() m.log = log |