metricallize
Uma forma simples de armazenar telemetria/logs em “banco de documentos” usando TinyDB, com 3 modos de persistência:
readable_sync: JSON legível (escreve no disco de forma direta)in_memory_async: JSON legível com cache em memória (escreve em batch, no flush/close)serialized_async: arquivo binário/comprimido (mais rápido/menor, escreve em background; exige flush/close)
Instalação
pip install metricallize
Para usar o modo serialized_async (serialização/compressão):
pip install "metricallize[serialized_async]"
Conceitos
- Você cria um
DocumentStorage - Você acessa qualquer table com
storage.db.table("nome") - O decorator
storage.capture(table="...")registra uma “execução” (status/duração/erro) nessa table
Campos automáticos gravados pelo capture:
ts:YYYY-MM-DD HH:MM:SS.xxx(UTC)started_at:YYYY-MM-DD HH:MM:SS.xxx(UTC)finished_at:YYYY-MM-DD HH:MM:SS.xxx(UTC)name:module.qualnameda funçãostatus:okouerrorduration:HH:MM:SSinputs: parâmetros serializados (com limites)output: retorno serializado (com limites)memory_before,memory_after,memory_peak,memory_delta:G.M.K(base 1024, K com 3 dígitos)- Em caso de erro:
exc_type,exc_msg
Path e versionamento (por mês)
Se você passar path como diretório (sem extensão), o arquivo é criado automaticamente em:
<path>/storage/YYYY_MM/day_DD.json (modos legíveis)
<path>/storage/YYYY_MM/day_DD.db (modo serialized)
Você pode controlar o nome base com name="...".
Uso: readable_sync (JSON legível)
from pathlib import Path
from metricallize import DocumentStorage
storage_dir = Path.cwd() / "data"
storage = DocumentStorage(path=storage_dir, mode="readable_sync", name="logger")
logger = storage.db.table("loggers")
logger.insert({"event": "startup"})
Uso: in_memory_async (cache em memória, JSON legível)
from pathlib import Path
from metricallize import DocumentStorage
storage_dir = Path.cwd() / "data"
storage = DocumentStorage(
path=storage_dir,
mode="in_memory_async",
name="trace",
write_cache_size=100_000,
)
trace = storage.db.table("trace")
trace.insert({"event": "step"})
storage.flush()
storage.close()
Uso: serialized_async (binário, assíncrono)
from pathlib import Path
from metricallize import DocumentStorage
storage_dir = Path.cwd() / "data"
storage = DocumentStorage(path=storage_dir, mode="serialized_async", name="trace")
trace = storage.db.table("trace")
trace.insert({"event": "step"})
storage.flush()
storage.close()
Decorator: capture
from pathlib import Path
from metricallize import DocumentStorage
storage = DocumentStorage(path=Path.cwd() / "data", mode="readable_sync")
table_name = "trace"
@storage.capture(table=table_name, capture_memory_mb=True)
def soma(a: int, b: int) -> int:
return a + b
@storage.capture(table=table_name)
def falha() -> None:
raise RuntimeError("boom")
soma(1, 2)
try:
falha()
except RuntimeError:
pass
# Se quiser reduzir overhead:
# @storage.capture(table=table_name, capture_memory_mb=False, capture_inputs=False, capture_output=False)
Publicação (TestPyPI e PyPI)
Build:
python -m pip install --upgrade build twine
python -m build
TestPyPI:
python -m twine upload --repository testpypi dist/*
PyPI:
python -m twine upload dist/*
Metadata
Release files for metricallize 0.1.1
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 | Actions |
|---|---|---|---|---|
| metricallize-0.1.1.tar.gz | 8.1 kB | Without provenance | Details for metricallize-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metricallize-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for metricallize-0.1.1-py3-none-any.whl |
Total release size: 16.1 kB
Release files / metricallize-0.1.1.tar.gz
| Download URL | metricallize-0.1.1.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5db11655b143f1cfa10abf7345cd75d15c5120861861a3653cf90c8736e767c3
|
|
BLAKE2b-256 checksum How to use checksums |
ddbeef58f42520ea5a7ec40f84c3fec04c3467c263a766e58278f5d2da0d8c69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / metricallize-0.1.1-py3-none-any.whl
| Download URL | metricallize-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
be8ef34df3961e94159950b80e9168f301b0276260594fef4a4d894830244bd9
|
|
BLAKE2b-256 checksum How to use checksums |
9e63299583adf58074118cb743d06b052d49b515f8c676d8429ccaf3433d0337
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for metricallize 0.1.1
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.