Multimeter
Multimeter is a python library that allows easy capturing of in-process run-time metrics for specific code parts. It is meant for tracking the behavior of a python script in terms of memory usage, cpu load or disk and network consumption as long as a specific part of the code is being run.
What it does
Within a python script an object of type Multimeter can be used to start measurements
that run a background thread and automatically capture values at a fixed schedule for
different metrics. When the measurement ends, the captured values can be automatically
stored in a file or send to time series databases.
How it works
The easiest way to measure the behavior of specific code is by wrapping it in a context manager:
import multimeter
...
mm = multimeter.Multimeter(multimeter.ResourceProbe())
with mm.measure(identifier='measurement-id') as measurement:
# Here the code whose performance should be measured
...
result = measurement.result
print(f"Start {result.start}")
print(f"End {result.end}")
print(f"Duration {result.duration}")
print(f"CPU avg values: {result.values('process.cpu_rate_user')}")
After the with statement the results can be taken from the measurement. The Result type
provides access to the captured metrics and the individual data points.
By providing a Storage object, the results can automatically be stored in the file
system or in time series databases:
mm = multimeter.Multimeter(multimeter.ResourceProbe())
mm.set_storage(multimeter.JsonFileStorage(save_directory=os.path.dirname(__file__)))
For more information take a look at the latest user guide.
Develop
Multimeter uses tox to build and test the library. Tox runs all tests on different python versions, can generate the documentation and run linters and style checks to improve the code quality. In order to install all the necessary python modules, please run:
pip install tox
Afterwards the tests can be run by just calling
tox
from the project directory. For this to work, you need to have multiple python interpreters installed. If you don't want to run the tests on all supported platforms just edit the tox.ini file and set
envlist = py36,py37,py38
to contain only the python version you want to use. Another option is to run tox with the additional command line argument '--skip_missing_interpreters' which skips python versions that aren't installed.
Documentation
The latest version of the documentation can always be found under https://docs.kant.ai/multimeter/latest.
The documentation is written in Markdown
and is located in the docs directory of the project.
It can be built into static HTML by using MkDocs.
In order to manually generate the documentation we can use tox to build the HTML pages from our markdown.
tox -e docs
Release
Releasing a new package version
Releasing new versions of multimeter is done using flit.
pip install flit
In order to be able to publish a new release, you need an account with PyPI or their respective test environment.
Add those accounts into your ~.pypirc:
[distutils]
index-servers =
pypi
pypitest
[pypi]
username: <my-user>
[pypitest]
repository: https://test.pypi.org/legacy/
username: <my-test-user>
Publishing a new release to test
flit publish --repository pypitest
Releasing a new version of the documentation
The package uses mike
to manage multiple versions of the documentation. The already generated documentation is kept
in the docs-deployment branch and will be automatically deployed, if the branch is pushed to
the repository.
In order to build a new version of the documentation, we need to use the corresponding tox environment:
VERSION_TAG='<my-version>' tox -e docs-release
The VERSION_TAG environment variable should be set to the new version in format '.'.
This will build the documentation and add it as new commits to the docs-deployment branch.
By pushing the updated branch to the gitlab repository, the documentation will be automatically deployed to the official documentation website.
Metadata
Release files for multimeter 0.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 |
|---|---|---|---|---|
| multimeter-0.1.tar.gz | 237.8 kB | Without provenance | Details for multimeter-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| multimeter-0.1-py3-none-any.whl | Python 3 | none | any | Details for multimeter-0.1-py3-none-any.whl |
Total release size: 263.4 kB
Release files / multimeter-0.1.tar.gz
| Download URL | multimeter-0.1.tar.gz |
|---|---|
| Size | 237.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f795e9746c14936da6af004bcae377c8a7e60ea6c6b821abb4d2f7d123f4ef29
|
|
BLAKE2b-256 checksum How to use checksums |
7908c8b395b173eed6a7b01285e38ece38dad22b3db6c8f225968238012394c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.26.0
|
Release files / multimeter-0.1-py3-none-any.whl
| Download URL | multimeter-0.1-py3-none-any.whl |
|---|---|
| Size | 25.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c7df1a52d32476af29eda9e1a66bc67e5bcd64d46fc4b027d872ed753be7c3ad
|
|
BLAKE2b-256 checksum How to use checksums |
9a998d6d11238dade2423ecf0c70eda965c37ea412b662111f16abb7378a9726
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.26.0
|
Security for multimeter 0.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.