diff --git a/fluentd/datadog_checks/fluentd/fluentd.py b/fluentd/datadog_checks/fluentd/fluentd.py index 4119d2ba69cb5..26858b1ce300c 100644 --- a/fluentd/datadog_checks/fluentd/fluentd.py +++ b/fluentd/datadog_checks/fluentd/fluentd.py @@ -8,7 +8,6 @@ # project from datadog_checks.checks import AgentCheck -from datadog_checks.utils.headers import headers class Fluentd(AgentCheck): @@ -17,9 +16,16 @@ class Fluentd(AgentCheck): GAUGES = ['retry_count', 'buffer_total_queued_size', 'buffer_queue_length'] _AVAILABLE_TAGS = frozenset(['plugin_id', 'type']) - def __init__(self, name, init_config, agentConfig, instances=None): - AgentCheck.__init__(self, name, init_config, agentConfig, instances) - self.default_timeout = init_config.get('default_timeout', self.DEFAULT_TIMEOUT) + def __init__(self, name, init_config, instances): + super(Fluentd, self).__init__(name, init_config, instances) + if not ('read_timeout' in self.instance or 'connect_timeout' in self.instance): + # `default_timeout` config option will be removed with Agent 5 + self.http.options['timeout'] = ( + self.instance.get('timeout') + or self.init_config.get('timeout') + or self.init_config.get('default_timeout') + or self.DEFAULT_TIMEOUT + ) """Tracks basic fluentd metrics via the monitor_agent plugin * number of retry_count @@ -51,11 +57,6 @@ def check(self, instance): 'fluentd_port:%s' % monitor_agent_port, ] + custom_tags - self.HTTP_CONFIG_REMAPPER = { - 'headers': {'name': 'headers', 'default': headers(self.agentConfig)}, - 'timeout': {'name': 'timeout', 'default': self.default_timeout}, - } - r = self.http.get(url) r.raise_for_status() status = r.json() diff --git a/fluentd/tests/conftest.py b/fluentd/tests/conftest.py index 5df61a6349d21..446a9d0e61fd5 100644 --- a/fluentd/tests/conftest.py +++ b/fluentd/tests/conftest.py @@ -37,4 +37,4 @@ def dd_environment(): @pytest.fixture def check(): - return Fluentd(CHECK_NAME, {}, {}) + return Fluentd(CHECK_NAME, {}, [DEFAULT_INSTANCE]) diff --git a/go_expvar/datadog_checks/go_expvar/go_expvar.py b/go_expvar/datadog_checks/go_expvar/go_expvar.py index 9818126e77229..ee68171e6c646 100644 --- a/go_expvar/datadog_checks/go_expvar/go_expvar.py +++ b/go_expvar/datadog_checks/go_expvar/go_expvar.py @@ -72,8 +72,8 @@ class GoExpvar(AgentCheck): 'ssl_keyfile': {'name': 'tls_private_key', 'default': None}, } - def __init__(self, name, init_config, agentConfig, instances=None): - AgentCheck.__init__(self, name, init_config, agentConfig, instances) + def __init__(self, name, init_config, instances): + super(GoExpvar, self).__init__(name, init_config, instances) self._regexes = {} self._last_gc_count = defaultdict(int) diff --git a/go_expvar/tests/conftest.py b/go_expvar/tests/conftest.py index 5aaa5f70ac920..82159acf2d0d6 100644 --- a/go_expvar/tests/conftest.py +++ b/go_expvar/tests/conftest.py @@ -42,4 +42,4 @@ def dd_environment(): @pytest.fixture def check(): - return GoExpvar(common.CHECK_NAME, {}, {}) + return GoExpvar(common.CHECK_NAME, {}, [common.INSTANCE]) diff --git a/harbor/datadog_checks/harbor/harbor.py b/harbor/datadog_checks/harbor/harbor.py index aafb072fba12a..8e31e871b17b4 100644 --- a/harbor/datadog_checks/harbor/harbor.py +++ b/harbor/datadog_checks/harbor/harbor.py @@ -14,8 +14,8 @@ class HarborCheck(AgentCheck): - def __init__(self, *args, **kwargs): - super(HarborCheck, self).__init__(*args, **kwargs) + def __init__(self, name, init_config, instances): + super(HarborCheck, self).__init__(name, init_config, instances) # Prevent the use of Basic Auth using `username` and `password` from the config file. del self.http.options['auth'] diff --git a/lighttpd/datadog_checks/lighttpd/lighttpd.py b/lighttpd/datadog_checks/lighttpd/lighttpd.py index f0c82c41c809f..37bfa76cc51a0 100644 --- a/lighttpd/datadog_checks/lighttpd/lighttpd.py +++ b/lighttpd/datadog_checks/lighttpd/lighttpd.py @@ -61,12 +61,12 @@ class Lighttpd(AgentCheck): HTTP_CONFIG_REMAPPER = {'user': {'name': 'username'}} - def __init__(self, name, init_config, instances=None): - AgentCheck.__init__(self, name, init_config, instances) + def __init__(self, name, init_config, instances): + super(Lighttpd, self).__init__(name, init_config, instances) self.assumed_url = {} - if instances is not None and 'auth_type' in instances[0]: - if instances[0]['auth_type'] == 'digest': + if 'auth_type' in self.instance: + if self.instance['auth_type'] == 'digest': auth = self.http.options['auth'] self.http.options['auth'] = requests.auth.HTTPDigestAuth(auth[0], auth[1]) diff --git a/teamcity/datadog_checks/teamcity/teamcity.py b/teamcity/datadog_checks/teamcity/teamcity.py index cd241e60c3f7b..30f8c73c0706c 100644 --- a/teamcity/datadog_checks/teamcity/teamcity.py +++ b/teamcity/datadog_checks/teamcity/teamcity.py @@ -27,9 +27,8 @@ class TeamCityCheck(AgentCheck): 'headers': {'name': 'headers', 'default': {"Accept": "application/json"}}, } - def __init__(self, name, init_config, agentConfig, instances=None): - AgentCheck.__init__(self, name, init_config, agentConfig, instances) - + def __init__(self, name, init_config, instances): + super(TeamCityCheck, self).__init__(name, init_config, instances) # Keep track of last build IDs per instance self.last_build_ids = {} diff --git a/teamcity/tests/test_teamcity.py b/teamcity/tests/test_teamcity.py index 6e54909d2d6ba..ff5f36f1d4e59 100644 --- a/teamcity/tests/test_teamcity.py +++ b/teamcity/tests/test_teamcity.py @@ -23,7 +23,7 @@ @pytest.mark.integration def test_build_event(aggregator): - teamcity = TeamCityCheck('teamcity', {}, {}) + teamcity = TeamCityCheck('teamcity', {}, [CONFIG]) with patch('requests.get', get_mock_first_build): teamcity.check(CONFIG['instances'][0])