Can we increment Prometheus counter metric using decorator in python?

Viewed 12

Can we increment Prometheus counter metric using decorator in python? Here is code snippet

REQUEST_COUNT = Counter('my_requests_total', 'HTTP Failures', ['method', 'endpoint'])

@REQUEST_COUNT.labels(method='get', endpoint='/hello').inc()
def process_request_count():
...

Error:

@REQUEST_COUNT.labels(method='get', endpoint='/hello').inc() SyntaxError: invalid syntax

0 Answers
Related