python-diamond / Diamond

Diamond is a python daemon that collects system metrics and publishes them to Graphite (and others). It is capable of collecting cpu, memory, network, i/o, load and disk metrics. Additionally, it features an API for implementing custom collectors for gathering metrics from almost any source.
http://diamond.readthedocs.org/
MIT License
1.74k stars 601 forks source link

Handlers are loaded differently from Collectors #586

Open DStape opened 7 years ago

DStape commented 7 years ago

All collectors are disabled by default. The "collectors_config_path" option under the 'server' section allows a user to specify a directory to read collector config files from, without having any references to collector names in the 'main' config file (as long as the collector-specific config file name matches an available collector class name). Inversely, all handlers are enabled by default. The "handlers_config_path" option under the 'server' section does the same thing as 'collectors_config_path', however the handler has to already be referenced in the 'handlers' field under the 'server' section. Only handlers listed in 'handlers' will be loaded. Is there a reason for this difference? From my current understanding of Diamond, it's not clear to me why these should differ.

Another related issue I've been experiencing is that it's not possible to disable handlers by setting enabled to False. If you want a handler to be disabled, it has to be removed from the 'handlers' option entirely. The main reason for this seems to be handler implementations don't seem to override the base Handler's 'self.enabled = True' (at least, the handlers I've looked at). There's one exception to that - when importing modules that cannot be found, handlers are typically disabled. However, they never seem to be disabled based on reading in the enabled value stored in the config. So despite having 'enabled=False' defined in either the 'main' config file under handlers/default or handlers/ or in a handler-specific config file, it never seems to take effect. And again, this default behavior differs from collectors which are disabled by default. One potential solution to this is instead of setting enabled to True in the base Handler class, set it to the value defined in the config. If there's no value defined in the config, then follow the same behaviour as collectors and make it disabled by default.

Any help or feedback on this would be much appreciated, thanks.