rycus86/prometheus_flask_exporter

View on GitHub
examples/connexion-pydantic/endpoint.py

Summary

Maintainability
A
0 mins
Test Coverage
from pydantic.dataclasses import dataclass
from main import metrics


@dataclass
class Info:
    foo: str


@metrics.summary('test_by_status', 'Test Request latencies by status', labels={
    'code': lambda r: r.status_code
})
def test() -> Info:
    return Info('Test version')


@metrics.content_type('text/plain')
@metrics.counter('test_plain', 'Counter for plain responses')
def plain() -> str:
    return 'Test plain response'