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

Raise exception to report when openmetrics process fails #5392

Merged
merged 2 commits into from
Jan 6, 2020
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also log a message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't raise alone raises the same exception?
Reading this: https://docs.python.org/3/tutorial/errors.html#handling-exceptions I thought it would. I wanted to keep the exact same exception to display in the status.

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