Skip to content

Commit 87eb5c5

Browse files
committed
Update metrics configuration documentation
Update the documentation for how to set up metrics events to use `metrics_configuration_factory` and do not bother to set `METRICS_EVENTS_TOPIC_PREFIX` in the mock case (it's not needed). Move `model_config` to the top of the class to make it somewhat more visible, following the coding style I've been trying to adopt elsewhere.
1 parent 3335dfa commit 87eb5c5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/user-guide/metrics/index.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,27 @@ See :ref:`configuration-details` for more info.
7575
7676
from pydantic import Field, HttpUrl
7777
from pydantic_settings import BaseSettings, SettingsConfigDict
78-
from safir.metrics import KafkaMetricsConfiguration, MetricsConfiguration
78+
from safir.metrics import (
79+
MetricsConfiguration,
80+
metrics_configuration_factory,
81+
)
7982
8083
8184
class Config(BaseSettings):
85+
model_config = SettingsConfigDict(
86+
env_prefix="MYAPP_", case_sensitive=False
87+
)
88+
8289
an_important_url: HttpUrl = Field(
8390
...,
8491
title="URL to something important",
8592
)
8693
8794
metrics: MetricsConfiguration = Field(
88-
default_factory=KafkaMetricsConfiguration,
95+
default_factory=metrics_configuration_factory,
8996
title="Metrics configuration",
9097
)
9198
92-
model_config = SettingsConfigDict(
93-
env_prefix="MYAPP_", case_sensitive=False
94-
)
95-
9699
97100
config = Config()
98101
@@ -251,7 +254,6 @@ You can make assertions about these published events in your unit tests.
251254
METRICS_APPLICATION=myapp
252255
METRICS_ENABLED=false
253256
METRICS_MOCK=true
254-
METRICS_EVENTS_TOPIC_PREFIX=what.ever
255257
256258
.. code-block:: python
257259

0 commit comments

Comments
 (0)