Skip to content

prefect.settings.models.client

ClientMetricsSettings

Bases: PrefectBaseSettings

Settings for controlling metrics reporting from the client

Source code in src/prefect/settings/models/client.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class ClientMetricsSettings(PrefectBaseSettings):
    """
    Settings for controlling metrics reporting from the client
    """

    model_config = _build_settings_config(("client", "metrics"))

    enabled: bool = Field(
        default=False,
        description="Whether or not to enable Prometheus metrics in the client.",
        # Using alias for backwards compatibility. Need to duplicate the prefix because
        # Pydantic does not allow the alias to be prefixed with the env_prefix. The AliasPath
        # needs to be first to ensure that init kwargs take precedence over env vars.
        validation_alias=AliasChoices(
            AliasPath("enabled"),
            "prefect_client_metrics_enabled",
            "prefect_client_enable_metrics",
        ),
    )

    port: int = Field(
        default=4201, description="The port to expose the client Prometheus metrics on."
    )

ClientSettings

Bases: PrefectBaseSettings

Settings for controlling API client behavior

Source code in src/prefect/settings/models/client.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class ClientSettings(PrefectBaseSettings):
    """
    Settings for controlling API client behavior
    """

    model_config = _build_settings_config(("client",))

    max_retries: int = Field(
        default=5,
        ge=0,
        description="""
        The maximum number of retries to perform on failed HTTP requests.
        Defaults to 5. Set to 0 to disable retries.
        See `PREFECT_CLIENT_RETRY_EXTRA_CODES` for details on which HTTP status codes are
        retried.
        """,
    )

    retry_jitter_factor: float = Field(
        default=0.2,
        ge=0.0,
        description="""
        A value greater than or equal to zero to control the amount of jitter added to retried
        client requests. Higher values introduce larger amounts of jitter.
        Set to 0 to disable jitter. See `clamped_poisson_interval` for details on the how jitter
        can affect retry lengths.
        """,
    )

    retry_extra_codes: ClientRetryExtraCodes = Field(
        default_factory=set,
        description="""
        A list of extra HTTP status codes to retry on. Defaults to an empty list.
        429, 502 and 503 are always retried. Please note that not all routes are idempotent and retrying
        may result in unexpected behavior.
        """,
        examples=["404,429,503", "429", {404, 429, 503}],
    )

    csrf_support_enabled: bool = Field(
        default=True,
        description="""
        Determines if CSRF token handling is active in the Prefect client for API
        requests.

        When enabled (`True`), the client automatically manages CSRF tokens by
        retrieving, storing, and including them in applicable state-changing requests
        """,
    )

    metrics: ClientMetricsSettings = Field(
        default_factory=ClientMetricsSettings,
        description="Settings for controlling metrics reporting from the client",
    )