Skip to content

pico-actuator v0.1.0

Latest

Choose a tag to compare

@dperezcabrera dperezcabrera released this 04 Jul 15:26

pico-actuator v0.1.0

First public release. Spring Boot-style actuator endpoints for pico-fastapi apps, auto-discovered by pico-boot — install it and the endpoints appear, zero config. No prior versions; no migration required.

Endpoints

Endpoint Purpose
GET /actuator/health Overall status + per-component detail (200/503)
GET /actuator/health/live Liveness — always UP; wire to livenessProbe
GET /actuator/health/ready Readiness — aggregate of all indicators
GET /actuator/info Static config + dynamic contributors
GET /actuator/metrics Prometheus default registry (metrics extra)

Highlights

  • Zero registration: any @component satisfying the HealthIndicator / InfoContributor protocol is collected via List[...] injection.
  • Failure isolation: a raising or hanging indicator reports its own component DOWN; the endpoint never 500s.
  • Concurrent checks with per-indicator timeout (actuator.check_timeout_seconds, default 5s); sync checks run in a worker thread and cannot stall the event loop.
  • Dependency-free liveness by design: restart storms during dependency outages are impossible.
  • Master switch: actuator.enabled: false makes every endpoint answer 404.
  • Composes with pico-otel: OTel metrics land in the registry /actuator/metrics serves.

Example

from pico_ioc import component

@component
class DbHealth:  # satisfies HealthIndicator — no registration needed
    name = "db"

    def check(self):
        self.engine.connect().close()
        return {"status": "UP"}
$ curl -s localhost:8000/actuator/health
{"status":"UP","components":{"db":{"status":"UP"}}}

Compatibility

  • Python 3.11+ · pico-ioc >= 2.2.0 · pico-fastapi >= 0.2.0

Tests

  • 14 tests. Pinned behaviors: concurrent execution (3 x 0.2s indicators finish in < 0.5s), per-indicator timeout reports DOWN without hanging the endpoint, failure isolation (a raising indicator never 500s), enabled: false disables all five routes, exposition validity via the official prometheus_client parser, and OpenMetrics content negotiation (# EOF terminator).

Install

pip install pico-actuator            # health/info
pip install pico-actuator[metrics]   # + Prometheus/OpenMetrics /metrics