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

Monitoring - Look for specific messages in retries #2451

Closed
wants to merge 5 commits into from
Closed
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
20 changes: 15 additions & 5 deletions system_tests/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
retry_503 = RetryErrors(ServiceUnavailable)


def _has_timeseries(result):
"""Return True if a time series query has non-empty results."""
return len(list(result)) > 0

UNKNOWN_METRIC_ERROR = ('The provided filter doesn\'t refer to any known '
'metric.')


def _unknown_metric(result):
"""Return True if the error describes writing to an unknown metric.."""
return UNKNOWN_METRIC_ERROR in result.message


class TestMonitoring(unittest.TestCase):

def test_fetch_metric_descriptor(self):
Expand Down Expand Up @@ -203,13 +216,10 @@ def test_write_point(self):

def _query_timeseries_with_retries():
MAX_RETRIES = 7

def _has_timeseries(result):
return len(list(result)) > 0

retry_result = RetryResult(_has_timeseries,
max_tries=MAX_RETRIES)(client.query)
return RetryErrors(BadRequest, max_tries=MAX_RETRIES)(retry_result)
return RetryErrors(BadRequest, error_predicate=_unknown_metric,
max_tries=MAX_RETRIES)(retry_result)

query = _query_timeseries_with_retries()(METRIC_TYPE, minutes=5)
timeseries_list = list(query)
Expand Down