Skip to main content

Module for keeping metrics about your application in Redis. The goal is to have an easy way to measure an application, and then expose these metrics through a HTTP API, either to process it in some web ui, or expose it to Prometheus.

Project description

Aka Stats

GitHub license Test/Lint PyPI

Aka (赤 - red in japanese) Stats.

Unified module for keeping stats in Redis.

The goal is to have an easy way to measure an application, and then expose these metrics through a HTTP API, either to process it in some web ui, or expose it to Prometheus.

from aka_stats import Stats, timer

with Stats() as stats:

    t = timer()
    ...

    stats("task_done", next(t).stat)

Or for asynchronouse code:

from aka_stats import Stats, timer

async def process_device(device_id: str):

    async with Stats() as stat:
        t = timer()
        ...
        stats("task_done", next(t).stat, extra_labels={"device_id": device_id})

Installation

And add this package to your project:

poetry add aka-stats

Usage Guide

Check out the usage guide here: Usage.md

Prometheus formatters

Information how to write a formatter is here: PrometheusFormatter.md

Optional Standalone HTTP API

Check out this guide here: Included HTTP API

Pytest plugin

This module is also a pytest plugin, providing a fixture mock_stats which collects stats instead of writing them to Redis.

def test_something(mock_stats):
    do_something()
    assert mock_stats[0] == (1612550961, "test", 1, None)

And the module with function:

def do_something():
    with Stats() as stats:
        stat("test", 1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aka-stats-21.2.5.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

aka_stats-21.2.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file aka-stats-21.2.5.tar.gz.

File metadata

  • Download URL: aka-stats-21.2.5.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.9.1 Linux/5.4.0-1039-azure

File hashes

Hashes for aka-stats-21.2.5.tar.gz
Algorithm Hash digest
SHA256 c67558fc14dad9675ffc8bf866b384fb28efe560ca16b6e75660f99c60452c0d
MD5 f1479ce86dab2306b44221f1d5a209e2
BLAKE2b-256 c77d3cec23cab6d8dd5db638e1a49d5f52ba8025c755a103c9d17f8290b2ced8

See more details on using hashes here.

File details

Details for the file aka_stats-21.2.5-py3-none-any.whl.

File metadata

  • Download URL: aka_stats-21.2.5-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.9.1 Linux/5.4.0-1039-azure

File hashes

Hashes for aka_stats-21.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1985937a8f14d700a6fce28d5cea799f001b9b853718bfdcc192f772ae1fb597
MD5 2a7a05281d73a4e583d643d13da18e43
BLAKE2b-256 26e20c1e77620fb7ceae7effad7f054f9defc90b99b3dca976be49f07fd7f1ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page