maping-client
Zero-config RED-metrics client for FastAPI/Starlette services, reporting to a mAPI-ng collector.
Open source. Start free on the hosted service (no card), or self-host the complete MIT stack.
Aggregates per-endpoint rate/errors/duration into a DDSketch client-side and
ships batched summaries over the Connect unary protocol, matching the wire
contract used by mAPI-ng's Go clients (maping/client). No MAPING_KEY set
means the middleware is a no-op: safe to add to any app.
Hosted or self-hosted
This client behaves identically either way: only the env vars you set differ.
- Hosted, forever free, no card. Sign up at
mapi-ng.com, create a key, set
MAPING_KEY. That is the whole setup: the client already defaults to the hosted ingest endpoint, soMAPING_ENDPOINTis not needed. - Self-hosted. Run the complete MIT stack yourself
(
make localfor dev,make upfor prod, see arhuman/maping). SetMAPING_KEYfor your own instance andMAPING_ENDPOINTto point at it.
Nothing here is held back to push you toward the hosted plan: the wire contract, the server, and this client are all MIT. Start hosted and move to self-hosting later, or the reverse, at any time. Convenience, not lock-in.
Status
Early development. Wire contract is pinned from
arhuman/maping's proto/maping/v1/maping.proto via scripts/sync-proto.sh;
see that repo's docs/adr/ for the design rationale behind the wire format
(DDSketch, ADR-0001; Connect protocol, ADR-0002).
Quickstart (once published)
Set your credentials (pick one; see "Hosted or self-hosted" above):
# Hosted (forever free, no card)
export MAPING_KEY="mk_live_..."
# Self-hosted
export MAPING_KEY="mk_live_..."
export MAPING_ENDPOINT="https://your-collector.internal"
Then the same code either way:
from contextlib import asynccontextmanager
from fastapi import FastAPI
from maping import Recorder
from maping.asgi import MapingMiddleware
recorder = Recorder() # reads MAPING_KEY, and MAPING_ENDPOINT if self-hosting, from env
@asynccontextmanager
async def lifespan(_: FastAPI):
await recorder.start()
yield
await recorder.shutdown() # must run AFTER the server stops accepting requests
fastapi_app = FastAPI(lifespan=lifespan)
# Wrap the WHOLE app -- not app.add_middleware() -- so this sits outside
# Starlette's ServerErrorMiddleware and observes the real final status even
# after an unhandled exception. See src/maping/asgi.py for why.
app = MapingMiddleware(fastapi_app, recorder=recorder)
See examples/fastapi_app.py for a fuller quickstart, including labelled
errors, aborted requests, and downstream-call timing.
Running tests
git clone https://github.com/arhuman/maping-python.git
cd maping-python
pip install -e ".[dev,zstd]"
ruff check src/ tests/ examples/
mypy src/
pytest tests/ -v
Same three commands the CI workflow runs on every push and PR (see
.github/workflows/_test.yml, the reusable workflow both ci.yml and
release.yml call).
Contributing
- Open an issue or PR against arhuman/maping-python.
- Keep changes scoped: one concern per PR, with tests.
ruff check,mypy, andpytestall have to pass before review; CI enforces this on every PR. - The wire contract under
src/maping/proto/v1/is pinned from the corearhuman/mapingrepo viascripts/sync-proto.sh(seePINNED_REFfor the exact pin). Don't hand-edit the generatedmaping_pb2.py/maping_pb2.pyi; change the pin and re-run the sync script instead.
Fidelity notes
- RED metrics (rate, errors, duration, DDSketch percentiles) match the Go client's wire contract exactly.
- InstanceWindow/USE gauges (CPU, memory, GC, goroutine-equivalents) are
best-effort approximations of the Go runtime stats the field names were
originally defined for; Python's GC/concurrency model has no exact
equivalent to Go's runtime introspection. See
src/maping/_sampler.py.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maping_client-0.1.0.tar.gz.
File metadata
- Download URL: maping_client-0.1.0.tar.gz
- Upload date:
- Size: 58.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90bc4848f55c8c84be23b151ac28a7cdfb4783e025cf40b9e08cfc11df087df7
|
|
| MD5 |
d10165396ba3c0ed288251209919654e
|
|
| BLAKE2b-256 |
2fd54866bcaa046780eb0bf39997254ed95019129d45637fa25b969cd57de609
|
Provenance
The following attestation bundles were made for maping_client-0.1.0.tar.gz:
Publisher:
release.yml on arhuman/maping-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maping_client-0.1.0.tar.gz -
Subject digest:
90bc4848f55c8c84be23b151ac28a7cdfb4783e025cf40b9e08cfc11df087df7 - Sigstore transparency entry: 2409600899
- Sigstore integration time:
-
Permalink:
arhuman/maping-python@93031f7b7696b4b1ae669e26030c0d23c0d8dbc3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/arhuman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@93031f7b7696b4b1ae669e26030c0d23c0d8dbc3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file maping_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: maping_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8b388f695017d5fa1edd76cbf2544f0a3e607b213d4f6d1fc5269af71a08a96
|
|
| MD5 |
d9a44f529745c0ae558795da23994ae2
|
|
| BLAKE2b-256 |
9906fdb9a60f226d4296dec448782a9d4eb47af51a4450fba424949d25a73476
|
Provenance
The following attestation bundles were made for maping_client-0.1.0-py3-none-any.whl:
Publisher:
release.yml on arhuman/maping-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
maping_client-0.1.0-py3-none-any.whl -
Subject digest:
b8b388f695017d5fa1edd76cbf2544f0a3e607b213d4f6d1fc5269af71a08a96 - Sigstore transparency entry: 2409601200
- Sigstore integration time:
-
Permalink:
arhuman/maping-python@93031f7b7696b4b1ae669e26030c0d23c0d8dbc3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/arhuman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@93031f7b7696b4b1ae669e26030c0d23c0d8dbc3 -
Trigger Event:
push
-
Statement type: