Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update __init__ method params #4243

Merged
merged 6 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions fluentd/datadog_checks/fluentd/fluentd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

# project
from datadog_checks.checks import AgentCheck
from datadog_checks.utils.headers import headers


class Fluentd(AgentCheck):
Expand All @@ -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
Expand Down Expand Up @@ -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},
ChristineTChen marked this conversation as resolved.
Show resolved Hide resolved
}

r = self.http.get(url)
r.raise_for_status()
status = r.json()
Expand Down
2 changes: 1 addition & 1 deletion fluentd/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def dd_environment():

@pytest.fixture
def check():
return Fluentd(CHECK_NAME, {}, {})
return Fluentd(CHECK_NAME, {}, [DEFAULT_INSTANCE])
4 changes: 2 additions & 2 deletions go_expvar/datadog_checks/go_expvar/go_expvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion go_expvar/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def dd_environment():

@pytest.fixture
def check():
return GoExpvar(common.CHECK_NAME, {}, {})
return GoExpvar(common.CHECK_NAME, {}, [common.INSTANCE])
4 changes: 2 additions & 2 deletions harbor/datadog_checks/harbor/harbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
8 changes: 4 additions & 4 deletions lighttpd/datadog_checks/lighttpd/lighttpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
5 changes: 2 additions & 3 deletions teamcity/datadog_checks/teamcity/teamcity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand Down
2 changes: 1 addition & 1 deletion teamcity/tests/test_teamcity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down