Skip to main content

lifebeacon

English | Українська


English

Lightweight monitoring library for microservices. Provides two independent components: periodic heartbeat pings and one-time critical alert notifications over HTTP.

Installation

pip install lifebeacon
uv add lifebeacon

Requirements

  • Python 3.11+

Components

Heartbeat

Sends periodic HTTP requests to a specified endpoint on a background daemon thread. Useful for signaling liveness to external monitoring systems.

from lifebeacon import Heartbeat

heartbeat = Heartbeat(
    url="https://monitoring.example.com/ping",
    interval=60,           # seconds between requests, default 120
    token="your-token",    # optional Bearer token
    method="POST",         # default POST
    timeout=5,             # request timeout in seconds, default 5
    service="my-service",  # any extra fields go into the JSON body
)

heartbeat.start()  # starts background thread, no effect if already running
# ...
heartbeat.stop()   # stops the thread and waits up to 5 seconds for it to finish

CriticalAlert

Sends a one-time HTTP request. Designed for notifying external systems about critical events such as failures or exceptions. Supports both async and sync usage.

The internal HTTP client is created lazily on first use and reused across subsequent calls. Call aclose() in async contexts or close() in sync contexts when the instance is no longer needed to release the underlying connection pool.

Async usage:

from lifebeacon import CriticalAlert

alert = CriticalAlert(
    url="https://monitoring.example.com/alert",
    token="your-token",    # optional Bearer token
    method="POST",         # default POST
    timeout=5,             # request timeout in seconds, default 5
    service="my-service",  # any extra fields become default JSON body fields
)

await alert.async_send(message="Database connection failed", level="critical")

await alert.aclose()

Sync usage:

from lifebeacon import CriticalAlert

alert = CriticalAlert(
    url="https://monitoring.example.com/alert",
    token="your-token",
    service="my-service",
)

alert.sync_send(message="Database connection failed", level="critical")

alert.close()

Extra keyword arguments passed to async_send() or sync_send() are merged with the instance-level defaults. Call-time values override instance-level defaults for duplicate keys.

Notes

  • All HTTP errors are silently suppressed in both components to avoid disrupting the host application.
  • Heartbeat runs on a daemon thread — it will not prevent the process from exiting.
  • CriticalAlert.aclose() / CriticalAlert.close() must be called explicitly when the instance is no longer needed.

Українська

Легковагова бібліотека моніторингу для мікросервісів. Надає два незалежних компоненти: періодичні heartbeat-пінги та одноразові сповіщення про критичні події через HTTP.

Встановлення

pip install lifebeacon
uv add lifebeacon

Вимоги

  • Python 3.11+

Компоненти

Heartbeat

Відправляє періодичні HTTP-запити на вказаний endpoint у фоновому daemon-потоці. Використовується для сигналізації про роботу сервісу зовнішнім системам моніторингу.

from lifebeacon import Heartbeat

heartbeat = Heartbeat(
    url="https://monitoring.example.com/ping",
    interval=60,           # секунди між запитами, за замовчуванням 120
    token="your-token",    # опціональний Bearer токен
    method="POST",         # за замовчуванням POST
    timeout=5,             # таймаут запиту в секундах, за замовчуванням 5
    service="my-service",  # будь-які додаткові поля потрапляють у тіло JSON
)

heartbeat.start()  # запускає фоновий потік, не має ефекту якщо вже запущений
# ...
heartbeat.stop()   # зупиняє потік і чекає до 5 секунд на завершення

CriticalAlert

Відправляє одноразовий HTTP-запит. Призначений для сповіщення зовнішніх систем про критичні події — збої, виключення тощо. Підтримує як async, так і sync використання.

HTTP-клієнт створюється ліниво при першому виклику і перевикористовується між наступними викликами. Викличте aclose() в async-контексті або close() в sync-контексті, коли інстанс більше не потрібен, щоб звільнити connection pool.

Async використання:

from lifebeacon import CriticalAlert

alert = CriticalAlert(
    url="https://monitoring.example.com/alert",
    token="your-token",    # опціональний Bearer токен
    method="POST",         # за замовчуванням POST
    timeout=5,             # таймаут запиту в секундах, за замовчуванням 5
    service="my-service",  # будь-які додаткові поля стають дефолтними полями JSON тіла
)

await alert.async_send(message="Database connection failed", level="critical")

await alert.aclose()

Sync використання:

from lifebeacon import CriticalAlert

alert = CriticalAlert(
    url="https://monitoring.example.com/alert",
    token="your-token",
    service="my-service",
)

alert.sync_send(message="Database connection failed", level="critical")

alert.close()

Додаткові keyword-аргументи, передані в async_send() або sync_send(), мерджаться з дефолтними полями інстансу. При дублюванні ключів — значення з виклику методу мають пріоритет.

Примітки

  • Всі HTTP-помилки мовчазно ігноруються в обох компонентах, щоб не переривати роботу хост-додатку.
  • Heartbeat працює в daemon-потоці — він не блокує завершення процесу.
  • CriticalAlert.aclose() / CriticalAlert.close() потрібно викликати явно коли інстанс більше не потрібен.

Metadata

Release files for lifebeacon 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lifebeacon 2.0.0
File Size Uploaded Provenance Actions
lifebeacon-2.0.0.tar.gz 7.2 kB Without provenance Details for lifebeacon-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lifebeacon 2.0.0
File Interpreter ABI Platform Actions
lifebeacon-2.0.0-py3-none-any.whl Python 3 none any Details for lifebeacon-2.0.0-py3-none-any.whl

Total release size: 14.0 kB

Release files / lifebeacon-2.0.0.tar.gz

Download URL lifebeacon-2.0.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4174c70cfb299c16d0c07f5714d5a101eeeb83f6442ddac7cf5ef8b815a4ef11
BLAKE2b-256 checksum
How to use checksums
3ca4df472379ca1e1ba6200dc4d3961d9cdeee4cd3ced2102eae4c9283fa7c0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lifebeacon-2.0.0-py3-none-any.whl

Download URL lifebeacon-2.0.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab21b8fd65a97ae1d24530d4f2c20e0b8bd8e901a9048652ef5fd5bcc709af87
BLAKE2b-256 checksum
How to use checksums
13637c7c0b37fc4713718b8eeabfcb1b6aff7de2ed1a12375d934058f91cd38c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lifebeacon 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page