Metadata-Version: 2.1
Name: aka-stats
Version: 21.1.4
Summary: 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.
Home-page: https://github.com/MichalMazurek/aka_stats
License: MIT
Author: Michal Mazurek
Author-email: mazurek.michal@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: fastapi
Requires-Dist: aioredis (>=1.3.1,<2.0.0)
Requires-Dist: fastapi (>=0.54.1,<0.55.0); extra == "fastapi"
Requires-Dist: pytz (>=2019.3,<2020.0)
Requires-Dist: redis (>=3.4.1,<4.0.0)
Project-URL: Repository, https://github.com/MichalMazurek/aka_stats
Description-Content-Type: text/markdown

# Aka Stats

[![GitHub license](https://img.shields.io/github/license/MichalMazurek/aka_stats)](https://github.com/MichalMazurek/aka_stats/blob/main/LICENSE)
[![Test/Lint](https://img.shields.io/github/workflow/status/MichalMazurek/aka_stats/Test%20code/main)](https://github.com/MichalMazurek/aka_stats/actions?query=workflow%3A%22Test+code%22)


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.

```python
from aka_stats import Stats, timer

with Stats() as stats:

    t = timer()
    ...

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

```

Or for asynchronouse code:

```python
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:

```bash
poetry add aka-stats
```

## Usage Guide

Check out the usage guide here: [Usage.md](Usage.md)

## Prometheus formatters

Information how to write a formatter is here: [PrometheusFormatters.md](PrometheusFormatters.md)

## Optional Standalone HTTP API

Check out this guide here: [Included HTTP API](<Included http api.md>)

