Skip to main content

Exposes an http endpoint exposing the health status of the app

Project description

pipeline status coverage report PyPI Status PyPI Version PyPI Python PyPI License PyPI Format

Applipy HealthCheck Metrics

pip install applipy_healthcheck

Exposes the health status of the applipy application through an HTTP endpoint with path /health.

Usage

Add the applipy_healthcheck.HealthCheckModule to your application. Optionally, define through which http server to expose the /health endpoint, if no name is given it defaults to the anonymous server:

# dev.yaml

app:
    name: demo
    modules:
        - applipy_healthcheck.HealthCheckModule

http.servers:
- name: internal
  host: 0.0.0.0
  port: 8080

healthcheck.server_name: internal

To run this test just install applipy_healthcheck and pyyaml and run the applipy application:

pip install applipy_healthcheck pyyaml
python -m applipy

You can now query http://0.0.0.0:8080/health and you should see OK being returned.

Custom health checks

applipy_healthcheck exposes the HealthChecker interface. You can implement your own and the health check endpoint will use it to determine the health of the system.

Example

Full healthcheck module config

All keys and their default values:

healthcheck:
  server_name: null
  verbose: false

Usage with custom HealthChecker

# mymodule.py

from applipy import Module
from applipy_healthcheck import HealthChecker


class MyHealthChecker(HealthChecker):

    async def check(self):
        is_healthy = True
        status_message = 'All OK'
        return is_healthy, status_message


class MyModule(Module):
    def configure(self, bind, register):
        bind(HealthChecker, MyHealthChecker)

    @classmethod
    def depends_on(cls):
        return HealthCheckModule,
# dev.yaml

app:
  name: test
  modules: [mymodule.MyModule]

http.servers:
- host: 0.0.0.0
  port: 8080

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

applipy_healthcheck-0.2.0.tar.gz (4.0 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page