Skip to content

Commit

Permalink
raise exception when openmetrics process fails so check reports it (#…
Browse files Browse the repository at this point in the history
…5392)

* raise exception when openmetrics process fails so check reports it, added a test

* update flake8
  • Loading branch information
Simwar authored and ChristineTChen committed Jan 6, 2020
1 parent ab6018d commit 5d023de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions linkerd/datadog_checks/linkerd/linkerd.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ def process(self, scraper_config, metric_transformers=None):
super(LinkerdCheck, self).process(scraper_config, metric_transformers=metric_transformers)
except Exception:
self.gauge(self.HEALTH_METRIC, 1, tags=tags)
raise
else:
self.gauge(self.HEALTH_METRIC, 0, tags=tags)
8 changes: 8 additions & 0 deletions linkerd/tests/test_linkerd.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ def test_linkerd_v2(aggregator):
)


def test_openmetrics_error(monkeypatch):
check = LinkerdCheck('linkerd', None, {}, [MOCK_INSTANCE])
with requests_mock.Mocker() as metric_request:
metric_request.get('http://fake.tld/prometheus', exc="Exception")
with pytest.raises(Exception):
check.check(MOCK_INSTANCE)


@pytest.mark.e2e
def test_e2e(dd_agent_check):
aggregator = dd_agent_check(rate=True)
Expand Down

0 comments on commit 5d023de

Please sign in to comment.