Skip to main content

pyp8s

Customisable prometheus exporter for your python application.

Currently not that much customisable, though.

Installation

python3 -m pip install pyp8s

Usage

Examples: https://github.com/pyp8s/examples

MetricsHandler implements a singleton.

from pyp8s import MetricsHandler as meh

if __name__ == '__main__':

    meh.serve(listen_address="0.0.0.0", listen_port=8081)

    meh.init("calls", "counter", "Number of calls I've received")
    meh.init("doorbells", "counter", "Number of doorbells I've answered")
    meh.init("yawns", "counter", "Quite self-explanatory")
    meh.init("mood", "gauge", "How do I feel myself from 1 to good enough")
    meh.init("giggles", "counter", "Measurement of the joke power.", init_value=0)

    meh.inc("calls", 1)

    meh.inc("doorbells", 100, can="have", extra="labels", since="2.1.0")
    meh.inc("doorbells", 9000, this="will", be="useful")

    meh.inc("yawns", 8, satisfying="yes")
    meh.inc("yawns", 1, satisfying="no", loud="yes")

    meh.set("mood", 3)
    meh.set("mood", 6)
curl 127.0.0.1:8081/metrics
# HELP http_get_requests Number GET requests accepted
# TYPE http_get_requests counter
http_get_requests{} 1
# HELP http_get_metrics Number times the metrics endpoint was called
# TYPE http_get_metrics counter
http_get_metrics{} 1
# HELP calls Number of calls I've received
# TYPE calls counter
calls{} 1
# HELP doorbells Number of doorbells I've answered
# TYPE doorbells counter
doorbells{can="have",extra="labels",since="2.1.0"} 100
doorbells{this="will",be="useful"} 9000
# HELP yawns Quite self-explanatory
# TYPE yawns counter
yawns{satisfying="yes"} 8
yawns{satisfying="no",loud="yes"} 1
# HELP mood How do I feel myself from 1 to good enough
# TYPE mood gauge
mood{} 6
# HELP giggles Measurement of the joke power.
# TYPE giggles counter
giggles{} 0

Usage without starting a server

When you only need this thing to collect and render metrics:

from pyp8s import MetricsHandler as meh

if __name__ == '__main__':
    meh.init("calls", "counter", "Number of calls I've received")

    print(meh.render())

render() returns a string object.

Test environment

python3.10 -m virtualenv --prompt="py3.10 pyp8s" .virtualenv
source .virtualenv/bin/activate

Reporting bugs

Please, use GitHub issues.

Requesting new functionality

Please, use GitHub issues.

Metadata

Release files for pyp8s 3.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for pyp8s 3.5.0
File Interpreter ABI Platform Actions
pyp8s-3.5.0-py3-none-any.whl Python 3 none any Details for pyp8s-3.5.0-py3-none-any.whl

Release files / pyp8s-3.5.0-py3-none-any.whl

Download URL pyp8s-3.5.0-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2bf6fe4acce4befd8efd12bded216f13867888cbcddace47d2b1a6dff33c14f
BLAKE2b-256 checksum
How to use checksums
56ae720a6be6225ae55dd4f5f7ff22bf2423abc4473913656bdcdf0723077a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.18

Security for pyp8s 3.5.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page