Library to collect runtime metrics for Python applications using spectator-py.
Project description
spectator-py-runtime-metrics
Library to collect runtime metrics for Python applications using spectator-py.
See the Atlas Documentation site for more details on spectator-py
.
Instrumenting Code
from spectator.registry import Registry
from runmetrics.stats_collector import StatsCollector
if __name__ == "__main__":
registry = Registry()
# optionally add a stable worker id tag to runtime metrics, for forked processes
StatsCollector(registry, worker_id=None).start()
Worker IDs
For long-running Python applications, it is common to use a forking process model to increase the
ability to handle load. Usually, these rely upon the pid
to uniquely identify the workers, but
some of these frameworks offer either a stable worker id or the ability to create stable worker id
values through the addition of callbacks.
Ideally, the worker id is a string in the range 0..N
, with N<16
in most cases. Most process
forking frameworks have a configuration setting for the maximum number of workers, which helps to
keep these values constrained.
Using raw str(os.getpid())
values as the worker id is not recommended, because it can lead to large
increases in metrics volume in the Atlas backend, if processes restart regularly over the lifetime of
an instance.
References
- Python
- Linux
Local Development
Install pyenv, possibly with Homebrew, and install a recent Python version.
make setup-venv
make test
make coverage
Project details
Release history Release notifications | RSS feed
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
Hashes for netflix_spectator_py_runtime_metrics-1.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c8eaf8457d100b8c7142a2d4f38b6fba5e12368b3f5f77259cf189f3324d733 |
|
MD5 | 221cf7a33810be4d80a165e241aeb214 |
|
BLAKE2b-256 | 78b0587a8c680527ff033342828c1c1d5b9e97eb95fbcd17f71a60608fd674d5 |
Hashes for netflix_spectator_py_runtime_metrics-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e36ec021ab5ded6398c28f3685ebdb7a795ea7473cb29ace075b63c3971aadb |
|
MD5 | 11222415fb5b3e2f0d9cb3dc4f3b74aa |
|
BLAKE2b-256 | be30b8f5f3a8efcf9e99ee3ee1cb248fe727b46536735521c8e762b3e1e9c9e8 |