This project has been archived by its maintainers, and is no longer receiving any updates.
craftainer-tool-observability
Observability building blocks for FastAPI services: a health check framework
with /live and /ready routes and generic dependency checks, structured
JSON logging, OpenTelemetry traces and metrics, a request-ID middleware and
opt-in request profiling. It is extracted from
template-fastapi and is an
instance of
template-python-package
(see docs/TEMPLATE.md for the conventions shared with
every instance). It never imports an application package or
craftainer_tool_crud; an import-linter contract enforces that.
Install
The distribution is craftainer-tool-observability, the import package
craftainer_tool_observability. The core needs FastAPI only; everything else
is an extra, so install what you use:
pip install craftainer-tool-observability # health framework, request IDs
pip install "craftainer-tool-observability[otel,redis]" # plus tracing/metrics/logs, Redis check
| Extra | Brings | Used by |
|---|---|---|
otel |
OpenTelemetry SDK, OTLP/HTTP exporters, logging, FastAPI and SQLAlchemy instrumentations (and SQLAlchemy, which otel.py imports for typing) |
logs.py, otel.py |
sqlalchemy |
SQLAlchemy (asyncio) | health.checks.postgres.PostgresCheck |
redis |
redis-py | health.checks.redis.RedisCheck |
s3 |
boto3 | health.checks.s3.S3Check |
http |
httpx | health.checks.http.HTTPCheck |
profiling |
pyinstrument | profiling.install_profiling |
logs.py and otel.py import OpenTelemetry at module level, so import them
only when [otel] is installed. The package root, health and middleware
import with no extra installed (a unit test proves it). Note that
opentelemetry-sqlalchemy instrumentation supports SQLAlchemy below 2.1 only,
hence the <2.1 bound.
Public API
| Module | Provides |
|---|---|
health |
HealthCheck, HealthCheckResult, HealthRegistry, build_health_router(get_registry, include_info=False, info_package=None) |
health.checks |
PostgresCheck, RedisCheck, S3Check, HTTPCheck (one module each) |
logs |
configure_logging(), shared_resource() |
otel |
configure_telemetry(), instrument_app(app), instrument_engine(engine) |
middleware |
RequestIDMiddleware, get_request_id() |
profiling |
install_profiling(app, *, enabled, production, query_param="profile") |
The details, environment variables and conventions are in
src/craftainer_tool_observability/README.md.
Versioning
SemVer, starting at 0.1.0. While the major version is 0, a minor release may
change the public API; pin craftainer-tool-observability>=0.x,<0.(x+1) until
1.0. Real-service integration tests for the dependency checks stay in
template-fastapi; the unit tests here use fakes and need no backing service.
Development
uv sync
prek run --all-files --hook-stage manual # lint, types, import contracts, unit tests (100% coverage)
uv run pytest tests/bench --no-cov # benchmarks (CodSpeed in CI)
Publishing to PyPI
Releases use PyPI trusted publishing
(GitHub OIDC): no API token is stored anywhere. make publish is a no-op
until you opt in, per repository:
- Register a "pending publisher" on the index before the first release
(PyPI: Your account, Publishing, "Add a new pending publisher"; TestPyPI
has its own, separate form on test.pypi.org). Enter the project name from
pyproject.toml, the GitHub owner and repository, the workflow namerelease.yml, and leave the environment empty (or use the onerelease.ymlruns under, if you add one). - Set the repository variable
PYPI_PUBLISH(Settings, Secrets and variables, Actions, Variables):- unset:
make publishprints a skip message and the release only attaches the sdist, wheel and SBOM to the GitHub release; testpypi: publish to TestPyPI;pypi: publish to PyPI.
- unset:
- Do the first release with
testpypias a dry run (a pre-release channel is enough), confirm thatmake release-checkinstalls the published version back from TestPyPI, then register the PyPI pending publisher and switch the variable topypi.
The version lives only in the git tag release.yml computes; pyproject.toml
stays at 0.0.0 and make build stamps RELEASE_VERSION into the build
without committing it.
License
Licensed under the GNU General Public License v3.0.
Metadata
Release files for craftainer-tool-observability 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| craftainer_tool_observability-0.1.2.tar.gz | 192.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| craftainer_tool_observability-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 228.3 kB
Release files / craftainer_tool_observability-0.1.2.tar.gz
| Download URL | craftainer_tool_observability-0.1.2.tar.gz |
|---|---|
| Size | 192.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe6b53b65831c4c4e3b19b121c418c757583ca03eb50f8e2b09cf0d2fbd4d86c
|
|
BLAKE2b-256 checksum How to use checksums |
18a7a771df3c7f0261fc5879d5f12082452502732da485c87897c4ad74b6bfbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / craftainer_tool_observability-0.1.2-py3-none-any.whl
| Download URL | craftainer_tool_observability-0.1.2-py3-none-any.whl |
|---|---|
| Size | 35.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a656a2924291ce86fb9e9e97f853c096aee014df7c82b80d58bc5134a5ed6b8
|
|
BLAKE2b-256 checksum How to use checksums |
e838e249286a10e74b953d60e0ffeba6bc102e88302dfd087dcddc87dba6c680
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for craftainer-tool-observability 0.1.2
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.