Metadata-Version: 2.1
Name: faust-prometheus-exporter
Version: 0.1.7
Summary: Module for exporting monitoring values for Prometheus
Home-page: https://gitlab.com/rocshers/python/faust-prometheus
License: MIT
Author: irocshers
Author-email: develop.iam@rocshers.com
Requires-Python: >=3.8,<4.0
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Archiving :: Packaging
Classifier: Topic :: System :: Software Distribution
Requires-Dist: faust-streaming (<1)
Requires-Dist: prometheus-client (<1)
Project-URL: Repository, https://gitlab.com/rocshers/python/faust-prometheus
Description-Content-Type: text/markdown

# Faust Prometheus Exporter

Module for exporting monitoring values for Prometheus

[![PyPI](https://img.shields.io/pypi/v/faust-prometheus-exporter)](https://pypi.org/project/faust-prometheus-exporter/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/faust-prometheus-exporter)](https://pypi.org/project/faust-prometheus-exporter/)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/faust-prometheus)](https://gitlab.com/rocshers/python/faust-prometheus)

[![Test coverage](https://codecov.io/gitlab/rocshers:python/faust-prometheus/graph/badge.svg?token=3C6SLDPHUC)](https://codecov.io/gitlab/rocshers:python/faust-prometheus)
[![Downloads](https://static.pepy.tech/badge/faust-prometheus-exporter)](https://pepy.tech/project/faust-prometheus-exporter)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/faust-prometheus)](https://gitlab.com/rocshers/python/faust-prometheus)

## Functionality

- Adds `/metrics` endpoint
- Gives basic `Prometheus-client` metrics
- Gives custom user`s metrics
- Adds internal `faust` metrics

## Installation

`pip install faust-prometheus-exporter`

## Quick start


```python
import faust
from faust_prometheus import FaustPrometheusExporter

app = faust.App('app', broker='localhost:9092')

# Adding the Prometheus Exporter
exporter = FaustPrometheusExporter(app)
```

```bash
# see default metrics
curl localhost:8000/metrics
```

## Playground

```python
import logging
from random import randint

import faust
from prometheus_client import Counter, Histogram

from faust_prometheus import FaustPrometheusExporter

logger = logging.getLogger('app')

# Prometheus custom metrics
prometheus_counter_topic_1_messages = Counter('topic_1_messages', 'Count of messages successfully processed from topic_1')
prometheus_histogram_size_messages = Histogram('size_messages', 'Histogram about messages size')

app = faust.App(
    'faust_prometheus',
    broker='localhost:9092',
)

# Adding the Prometheus Exporter
exporter = FaustPrometheusExporter(app)

topic_1 = app.topic('topic_1')

@app.agent(topic_1)
async def agent_topic_1(messages: faust.Stream[str]):
    async for message in messages:
        logger.info(f'Received topic_1 message: {message}')
        prometheus_counter_topic_1_messages.inc()
        prometheus_histogram_size_messages.observe(len(message))

@app.timer(interval=1.0)
async def example_sender(app):
    await topic_1.send(value='Nisi lorem ullamco veniam elit' * randint(1, 10))

if __name__ == '__main__':
    app.main()

```

## Contribute

Issue Tracker: <https://gitlab.com/rocshers/python/faust-prometheus/-/issues>  
Source Code: <https://gitlab.com/rocshers/python/faust-prometheus>

Before adding changes:

```bash
make install-dev
```

After changes:

```bash
make format test
```

