Exemplo n.º 1
0
def heartbeat(request):
    all_checks = checks_registry.get_checks(include_deployment_checks=not settings.DEBUG)

    details = {}
    statuses = {}
    level = 0

    for check in all_checks:
        detail = heartbeat_check_detail(check)
        statuses[check.__name__] = detail['status']
        level = max(level, detail['level'])
        if detail['level'] > 0:
            details[check.__name__] = detail

    if level < checks_messages.WARNING:
        res_status = status.HTTP_200_OK
        statsd.incr('heartbeat.pass')
    else:
        res_status = status.HTTP_500_INTERNAL_SERVER_ERROR
        statsd.incr('heartbeat.fail')

    return Response({
        'status': heartbeat_level_to_text(level),
        'checks': statuses,
        'details': details,
    }, status=res_status)
Exemplo n.º 2
0
def heartbeat(request):
    all_checks = checks_registry.get_checks(include_deployment_checks=not settings.DEBUG)

    details = {}
    statuses = {}
    level = 0

    for check in all_checks:
        detail = heartbeat_check_detail(check)
        statuses[check.__name__] = detail['status']
        level = max(level, detail['level'])
        if detail['level'] > 0:
            details[check.__name__] = detail

    if level < checks_messages.WARNING:
        res_status = status.HTTP_200_OK
        statsd.incr('heartbeat.pass')
    else:
        res_status = status.HTTP_500_INTERNAL_SERVER_ERROR
        statsd.incr('heartbeat.fail')

    return Response({
        'status': heartbeat_level_to_text(level),
        'checks': statuses,
        'details': details,
    }, status=res_status)
Exemplo n.º 3
0
def heartbeat(request):
    all_checks = checks_registry.get_checks(include_deployment_checks=not settings.DEBUG)

    details = {}
    statuses = {}
    level = 0

    for check in all_checks:
        detail = heartbeat_check_detail(check)
        statuses[check.__name__] = detail['status']
        level = max(level, detail['level'])
        if detail['level'] > 0:
            details[check.__name__] = detail

    if level < checks_messages.WARNING:
        status_code = 200
    else:
        status_code = 500

    payload = {
        'status': heartbeat_level_to_text(level),
        'checks': statuses,
        'details': details,
    }
    return JsonResponse(payload, status=status_code)
Exemplo n.º 4
0
def heartbeat(request):
    all_checks = checks_registry.get_checks(
        include_deployment_checks=not settings.DEBUG)

    details = {}
    statuses = {}
    level = 0

    for check in all_checks:
        detail = heartbeat_check_detail(check)
        statuses[check.__name__] = detail['status']
        level = max(level, detail['level'])
        if detail['level'] > 0:
            details[check.__name__] = detail

    if level < checks_messages.WARNING:
        status_code = 200
    else:
        status_code = 500

    payload = {
        'status': heartbeat_level_to_text(level),
        'checks': statuses,
        'details': details,
    }
    return JsonResponse(payload, status=status_code)
Exemplo n.º 5
0
def simulate_checks():
    app_configs = apps.app_configs
    errors = []
    all_checks = registry.get_checks(False)
    rest_registration_checks = [
        check for check in all_checks
        if check.__module__.startswith('rest_registration.')
    ]
    for check in rest_registration_checks:
        errors.extend(check(app_configs))
    return errors
Exemplo n.º 6
0
 def test_registered(self):
     """checks.subclasses_available is a registered check."""
     registered_checks = registry.get_checks()
     self.assertIn(checks.subclasses_available, registered_checks)
Exemplo n.º 7
0
 def test_registered(self):
     """checks.polymorphic_installed is a registered check."""
     registered_checks = registry.get_checks()
     self.assertIn(checks.polymorphic_installed, registered_checks)
Exemplo n.º 8
0
 def test_registered_checks(self):
     """The correct checks are registered."""
     registered_checks = registry.get_checks()
     self.assertIn(checks.sirtrevor_installed, registered_checks)