Skip to content

Commit d5375f6

Browse files
authored
Do not fail if no tags are provided in the config (#17598)
* Do not fail if no tags are provided in the config * remove breakpoint() * added changelog and fix broken test * nit
1 parent a122e32 commit d5375f6

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

vault/changelog.d/17598.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not fail if no tags are provided in the config

vault/datadog_checks/vault/check.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ def parse_config(self):
213213
self._api = Api(**methods)
214214

215215
tags = [f'api_url:{self._api_url}']
216-
tags.extend(self.config.tags)
216+
if self.config.tags:
217+
tags.extend(self.config.tags)
217218
self._tags = tuple(tags)
218219

219220
def configure_scrapers(self):

vault/tests/test_vault.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ def test_bad_config(self, aggregator, dd_run_check, use_openmetrics):
3333

3434
aggregator.assert_service_check(Vault.SERVICE_CHECK_CONNECT, count=0)
3535

36+
@pytest.mark.parametrize('use_openmetrics', [False, True], indirect=True)
37+
def test_no_extra_tags(self, aggregator, dd_run_check, use_openmetrics):
38+
instance = {'use_openmetrics': use_openmetrics}
39+
instance.update(INSTANCES['main'])
40+
instance.pop('tags')
41+
42+
c = Vault(Vault.CHECK_NAME, {}, [instance])
43+
44+
tag = ['api_url:{}'.format(INSTANCES['main']['api_url'])]
45+
dd_run_check(c)
46+
47+
aggregator.assert_service_check(Vault.SERVICE_CHECK_CONNECT, status=Vault.OK, count=1, tags=tag)
48+
3649
@pytest.mark.parametrize('use_openmetrics', [False, True], indirect=True)
3750
def test_unsupported_api_version_fallback(self, aggregator, dd_run_check, use_openmetrics):
3851
instance = {'use_openmetrics': use_openmetrics}

0 commit comments

Comments
 (0)