cronitor
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: cronitor | ||
| Version: 4.5.0 | ||
| Version: 4.6.0 | ||
| Summary: A lightweight Python client for Cronitor. | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/cronitorio/cronitor-python |
| requests | ||
| pyyaml | ||
| humanize | ||
| urllib3 |
+9
-14
@@ -15,10 +15,2 @@ import logging | ||
| CONFIG_KEYS = ( | ||
| 'api_key', | ||
| 'api_version', | ||
| 'environment', | ||
| ) | ||
| MONITOR_TYPES = ('job', 'heartbeat', 'check') | ||
| YAML_KEYS = CONFIG_KEYS + tuple(map(lambda t: '{}s'.format(t), MONITOR_TYPES)) | ||
| # configuration variables | ||
@@ -57,3 +49,4 @@ api_key = os.getenv('CRONITOR_API_KEY', None) | ||
| def job(key, include_output=True): | ||
| # include_output is deprecated in favor of log_output and can be removed in 5.0 release | ||
| def job(key, env=None, log_output=True, include_output=True): | ||
| def wrapper(func): | ||
@@ -64,3 +57,3 @@ @wraps(func) | ||
| monitor = Monitor(key) | ||
| monitor = Monitor(key, env=env) | ||
| # use start as the series param to match run/fail/complete correctly | ||
@@ -76,3 +69,3 @@ monitor.ping(state=State.RUN, series=start) | ||
| duration = datetime.now().timestamp() - start | ||
| message = str(out) if include_output else None | ||
| message = str(out) if all([log_output, include_output]) else None | ||
| monitor.ping(state=State.COMPLETE, message=message, metrics={'duration': duration}, series=start) | ||
@@ -99,9 +92,11 @@ return out | ||
| monitors = Monitor.put(monitors=config, rollback=rollback, format=YAML) | ||
| job_count = len(monitors['jobs']) if 'jobs' in monitors else 0 | ||
| check_count = len(monitors['checks']) if 'checks' in monitors else 0 | ||
| heartbeat_count = len(monitors['heartbeats']) if 'heartbeats' in monitors else 0 | ||
| job_count = len(monitors.get('jobs', [])) | ||
| check_count = len(monitors.get('checks', [])) | ||
| heartbeat_count = len(monitors.get('heartbeats', [])) | ||
| total_count = sum([job_count, check_count, heartbeat_count]) | ||
| logger.info('{} monitor{} {}'.format(total_count, 's' if total_count != 1 else '', 'validated.' if rollback else 'synced.',)) | ||
| return True | ||
| except (yaml.YAMLError, ConfigValidationError, APIValidationError, APIError, AuthenticationError) as e: | ||
| logger.error(e) | ||
| return False | ||
@@ -108,0 +103,0 @@ def read_config(path=None, output=False): |
@@ -24,3 +24,2 @@ import time | ||
| backoff_factor=backoff_factor, | ||
| method_whitelist=False, | ||
| ) | ||
@@ -27,0 +26,0 @@ adapter = HTTPAdapter(max_retries=retry) |
@@ -71,2 +71,5 @@ import os | ||
| def setUp(self): | ||
| cronitor.api_key = FAKE_API_KEY | ||
| @patch('cronitor.Monitor.ping') | ||
@@ -78,3 +81,2 @@ def test_ping_wraps_function_success(self, mocked_ping): | ||
| @patch('cronitor.Monitor.ping') | ||
@@ -86,2 +88,8 @@ def test_ping_wraps_function_raises_exception(self, mocked_ping): | ||
| @patch('cronitor.Monitor.ping') | ||
| @patch('cronitor.Monitor.__init__') | ||
| def test_ping_with_non_default_env(self, mocked_monitor, mocked_ping): | ||
| mocked_monitor.return_value = None | ||
| self.staging_env_function_call() | ||
| mocked_monitor.assert_has_calls([call('ping-decorator-test', env='staging')]) | ||
@@ -96,3 +104,7 @@ @cronitor.job('ping-decorator-test') | ||
| @cronitor.job('ping-decorator-test', env='staging') | ||
| def staging_env_function_call(self): | ||
| return | ||
+1
-1
| Metadata-Version: 2.1 | ||
| Name: cronitor | ||
| Version: 4.5.0 | ||
| Version: 4.6.0 | ||
| Summary: A lightweight Python client for Cronitor. | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/cronitorio/cronitor-python |
+2
-1
@@ -8,3 +8,3 @@ from setuptools import setup, find_packages | ||
| name='cronitor', | ||
| version='4.5.0', | ||
| version='4.6.0', | ||
| packages=find_packages(), | ||
@@ -22,4 +22,5 @@ url='https://github.com/cronitorio/cronitor-python', | ||
| 'humanize', | ||
| 'urllib3' | ||
| ], | ||
| entry_points=dict(console_scripts=['cronitor = cronitor.__main__:main']) | ||
| ) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
65940
0.62%689
1.03%