Skip to main content

A modern, composable health monitoring library for Python applications with hierarchical status aggregation, async support, and flexible configuration system.

Project description

Pygnosis

Asynchronous health checks for Python services.

CI codecov

Features

  • Flexible health indicators (define your own checks)
  • Composable architecture (nest indicators into trees)
  • Full async/await support
  • Type hints throughout
  • Graceful error handling

Installation

pip install pygnosis

Quick start

import asyncio
from pygnosis import Health, HealthIndicator, Status, CompositeHealthIndicator


class DatabaseHealthIndicator(HealthIndicator):
    def get_name(self) -> str:
        return "database"

    async def get_health(self) -> Health:
        try:
            return Health.builder(Status.UP).with_detail("connections", 10).build()
        except Exception as e:
            return Health.builder(Status.DOWN).with_exception(e).build()


class RedisHealthIndicator(HealthIndicator):
    def get_name(self) -> str:
        return "redis"

    async def get_health(self) -> Health:
        return Health.builder(Status.UP).build()


async def main():
    composite = CompositeHealthIndicator(
        name="app",
        indicators=[DatabaseHealthIndicator(), RedisHealthIndicator()],
    )
    health = await composite.get_health()
    print(f"Status: {health.status}")
    print(f"Components: {health.components}")


if __name__ == "__main__":
    asyncio.run(main())

Development with uv

uv sync --group dev
uv run ruff check src/ tests/
uv run pytest

Building the package

uv build

Documentation

Sphinx docs are built in CI. Locally:

uv sync --group docs
uv run sphinx-build -b html docs docs/_build/html

License

MIT License — see LICENSE

Contributing

Contributions are welcome. See CONTRIBUTING.md for guidelines.

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

pygnosis-0.1.2.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygnosis-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pygnosis-0.1.2.tar.gz.

File metadata

  • Download URL: pygnosis-0.1.2.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pygnosis-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9889d3a9d339ffaa4fe180cebe6ef1b09f12a8a2bdd1403fafbbd3afd45e3fd3
MD5 bbf5205aee4ae87e59748fed2b851b99
BLAKE2b-256 e27dd61c6f0f512f667a89bbcbbad4712b779a92d15ae6675db2a2865d4a2949

See more details on using hashes here.

File details

Details for the file pygnosis-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pygnosis-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pygnosis-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f4e84ecd08419006b2ce1f2365595b05f221863c35f178a13d6ea97a0aafc0f4
MD5 d733c27671932a8a46c31c4ddfad3efc
BLAKE2b-256 45e8267ba35ee587194255b703ac6e06f90a1d5e988afb9046e74a649919aa42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page