Debian Codegraph @

docs/examples/plugins/prometheus/using_prometheus_exporter.py

raw
1 from litestar import Litestar
2 from litestar.plugins.prometheus import PrometheusConfig, PrometheusController
3
4
5 def create_app(group_path: bool = False):
6 # Default app name and prefix is litestar.
7 prometheus_config = PrometheusConfig(group_path=group_path)
8
9 # By default the metrics are available in prometheus format and the path is set to '/metrics'.
10 # If you want to change the path and format you can do it by subclassing the PrometheusController class.
11
12 # Creating the litestar app instance with our custom PrometheusConfig and PrometheusController.
13 return Litestar(route_handlers=[PrometheusController], middleware=[prometheus_config.middleware])