You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/monitoring/metrics.rst
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,9 @@ The ``BaseMetricsConfig`` class is used to configure metrics, and it accepts the
50
50
51
51
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.
52
52
53
+
5. ``openmetrics_format`` (**bool**) - A flag indicating whether to generate metrics in ``OpenMetrics`` format. Default is ``False``.
54
+
55
+
53
56
You can also set up a **global** ``prometheus_client.REGISTRY`` in ``MetricsConfig`` to support your **global** metrics,
54
57
but it is better to use your own **non-global** registry or leave the **default** registry.
55
58
@@ -64,21 +67,22 @@ but it is better to use your own **non-global** registry or leave the **default*
64
67
include_metrics_endpoint=True, # Adding an endpoint /metrics
65
68
)
66
69
# Using default metrics_prefix "fastapi"
70
+
# Using default metrics export format (``openmetrics_format=True`` for use ``OpenMetrics`` format)
67
71
# Using default registry
68
72
69
73
Exporting
70
74
~~~~~~~~~~~~~~~~~~
71
75
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``.
73
77
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.
75
79
76
80
.. code-block:: python
77
81
:caption: Exporting metrics
78
82
79
83
from asgi_monitor.metrics import get_latest_metrics
0 commit comments