Skip to content

Commit a573656

Browse files
committed
Update docs and litestar example
1 parent 9d62515 commit a573656

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

docs/integrations/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ So **asgi-monitor** is rushing to the rescue.
126126
middlewares = [build_tracing_middleware(trace_config), build_metrics_middleware(metrics_config)]
127127
128128
app = Litestar([index], middleware=middlewares, logging_config=None)
129-
130-
add_metrics_endpoint(app, metrics_config.registry)
129+
add_metrics_endpoint(app, metrics_config.registry, openmetrics_format=False)
131130
132131
return app
133132

docs/monitoring/metrics.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ The ``BaseMetricsConfig`` class is used to configure metrics, and it accepts the
5050

5151
4. ``include_trace_exemplar`` (**bool**) - Whether to include trace exemplars in the metrics. Default is ``False``. This is only necessary if **tracing** is configured and metrics are collected in the ``OpenMetrics`` format.
5252

53+
5. ``openmetrics_format`` (**bool**) - A flag indicating whether to generate metrics in ``OpenMetrics`` format. Default is ``False``.
54+
55+
5356
You can also set up a **global** ``prometheus_client.REGISTRY`` in ``MetricsConfig`` to support your **global** metrics,
5457
but it is better to use your own **non-global** registry or leave the **default** registry.
5558

@@ -64,21 +67,22 @@ but it is better to use your own **non-global** registry or leave the **default*
6467
include_metrics_endpoint=True, # Adding an endpoint /metrics
6568
)
6669
# Using default metrics_prefix "fastapi"
70+
# Using default metrics export format (``openmetrics_format=True`` for use ``OpenMetrics`` format)
6771
# Using default registry
6872
6973
Exporting
7074
~~~~~~~~~~~~~~~~~~
7175

72-
If you are using integration with the web framework, you can add metric exports via the config by setting ``include_metrics_endpoint`` to ``True`` or by explicitly calling ``add_metrics_endpoint``. In this case, the metrics will be exported via the **/metrics** endpoint in ``text/plain`` format.
76+
If you are using integration with the web framework, you can add metric exports via the config by setting ``include_metrics_endpoint`` to ``True`` or by explicitly calling ``add_metrics_endpoint``.
7377

74-
In case you need to **customize the endpoint**, add **protection**, use the **OpenMetrics** format, or just use **another method for delivering** metrics, then you should use the built-in ``get_latest_metrics`` function.
78+
In case you need to **customize the endpoint**, add **protection** or just use **another method for delivering** metrics, then you should use the built-in ``get_latest_metrics`` function.
7579

7680
.. code-block:: python
7781
:caption: Exporting metrics
7882
7983
from asgi_monitor.metrics import get_latest_metrics
8084
81-
metrics = get_latest_metrics(registry=registry, openmetrics_format=True)
85+
metrics = get_latest_metrics(registry=registry)
8286
8387
Gunicorn
8488
~~~~~~~~~~~~~~~~~~

examples/litestar_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def create_app() -> Litestar:
4646

4747
app = Litestar([index], middleware=middlewares, logging_config=None)
4848

49-
add_metrics_endpoint(app, metrics_config.registry)
49+
add_metrics_endpoint(app, metrics_config.registry, openmetrics_format=False)
5050

5151
return app
5252

0 commit comments

Comments
 (0)