Bases: BaseModel
Monitoring Settings.
See starlette-exporter <https://github.com/stephenhillier/starlette_exporter#options>_ documentation.
.. note::
You can pass here any extra option supported by ``starlette-exporter``,
even if it is not mentioned in documentation.
Examples
.. code-block:: bash
DATA_RENTGEN__SERVER__MONITORING__ENABLED=True
DATA_RENTGEN__SERVER__MONITORING__SKIP_PATHS=["/some/path"]
DATA_RENTGEN__SERVER__MONITORING__SKIP_METHODS=["OPTIONS"]
Source code in data_rentgen/server/settings/monitoring.py
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 | class MonitoringSettings(BaseModel):
"""Monitoring Settings.
See `starlette-exporter <https://github.com/stephenhillier/starlette_exporter#options>`_ documentation.
.. note::
You can pass here any extra option supported by ``starlette-exporter``,
even if it is not mentioned in documentation.
Examples
--------
.. code-block:: bash
DATA_RENTGEN__SERVER__MONITORING__ENABLED=True
DATA_RENTGEN__SERVER__MONITORING__SKIP_PATHS=["/some/path"]
DATA_RENTGEN__SERVER__MONITORING__SKIP_METHODS=["OPTIONS"]
"""
enabled: bool = Field(default=True, description="Set to ``True`` to enable middleware")
labels: dict[str, str] = Field(
default_factory=dict,
description="""Custom labels added to all metrics, e.g. ``{"instance": "production"}``""",
)
skip_paths: set[str] = Field(
default_factory=set,
description="Custom paths should be skipped from metrics, like ``/some/endpoint``",
)
skip_methods: set[str] = Field(
default={"OPTIONS"},
description="HTTP methods which should be excluded from metrics",
)
# These will be new defaults in starlette-exporter 0.18:
# https://github.com/stephenhillier/starlette_exporter/issues/79
group_paths: bool = Field(
default=True,
description=textwrap.dedent(
"""
If ``True`` (recommended), add request path to metrics literally as described
in OpenAPI schema, e.g. ``/namespaces/{id}``, without substitution with path real values.
If ``False``, all real request paths to metrics, e.g. ``/namespaces/123``.
""",
),
)
filter_unhandled_paths: bool = Field(
default=True,
description=textwrap.dedent(
"""
If ``True``, add metrics for paths only mentioned in OpenAPI schema.
If ``False``, add all requested paths to metrics.
""",
),
)
model_config = ConfigDict(extra="allow")
|