MockMetricsConfiguration#

pydantic model safir.metrics.MockMetricsConfiguration#

Metrics configuration when metrics publishing is mocked.

Parameters:
  • _case_sensitive (bool | None, default: None)

  • _nested_model_default_partial_update (bool | None, default: None)

  • _env_prefix (str | None, default: None)

  • _env_prefix_target (Literal['variable', 'alias', 'all'] | None, default: None)

  • _env_file (Path | str | Sequence[Path | str] | None, default: PosixPath('.'))

  • _env_file_encoding (str | None, default: None)

  • _env_ignore_empty (bool | None, default: None)

  • _env_nested_delimiter (str | None, default: None)

  • _env_nested_max_split (int | None, default: None)

  • _env_parse_none_str (str | None, default: None)

  • _env_parse_enums (bool | None, default: None)

  • _cli_prog_name (str | None, default: None)

  • _cli_parse_args (bool | list[str] | tuple[str, ...] | None, default: None)

  • _cli_settings_source (CliSettingsSource[Any] | None, default: None)

  • _cli_parse_none_str (str | None, default: None)

  • _cli_hide_none_type (bool | None, default: None)

  • _cli_avoid_json (bool | None, default: None)

  • _cli_enforce_required (bool | None, default: None)

  • _cli_use_class_docs_for_groups (bool | None, default: None)

  • _cli_exit_on_error (bool | None, default: None)

  • _cli_prefix (str | None, default: None)

  • _cli_flag_prefix_char (str | None, default: None)

  • _cli_implicit_flags (bool | Literal['dual', 'toggle'] | None, default: None)

  • _cli_ignore_unknown_args (bool | None, default: None)

  • _cli_kebab_case (bool | Literal['all', 'no_enums'] | None, default: None)

  • _cli_shortcuts (Mapping[str, str | list[str]] | None, default: None)

  • _secrets_dir (Path | str | Sequence[Path | str] | None, default: None)

  • _build_sources (tuple[tuple[PydanticBaseSettingsSource, ...], dict[str, Any]] | None, default: None)

  • values (Any)

Config:
  • extra: str = ignore

  • populate_by_name: bool = True

  • validate_by_alias: bool = True

  • validate_by_name: bool = True

Fields:
  • application ()

  • enabled (Annotated[bool, pydantic.functional_validators.AfterValidator(func=safir.metrics._config.MockMetricsConfiguration.

  • events ()

  • mock (Annotated[bool, pydantic.functional_validators.AfterValidator(func=safir.metrics._config.MockMetricsConfiguration.

field application: str [Required]#

The name of the application that is emitting these metrics

field enabled: <lambda>)] [Required]#

If set to false, no events will be sent and all calls to publish events will be no-ops.

Constraints:
  • func = <function MockMetricsConfiguration.<lambda> at 0x7f000ea1b480>

field events: EventsConfiguration [Optional]#
field mock: <lambda>)] [Required]#

If set to true, all event publishers will be unittest.mock.MagicMock instances which will record all calls to their publish methods.

Constraints:
  • func = <function MockMetricsConfiguration.<lambda> at 0x7f000ea1b740>

classmethod settings_customise_sources(settings_cls, init_settings, env_settings, dotenv_settings, file_secret_settings)#

Define the sources and their order for loading the settings values.

Args:

settings_cls: The Settings class. init_settings: The InitSettingsSource instance. env_settings: The EnvSettingsSource instance. dotenv_settings: The DotEnvSettingsSource instance. file_secret_settings: The SecretsSettingsSource instance.

Returns:

A tuple containing the sources and their order for loading the settings values.

Parameters:
  • settings_cls (type[BaseSettings])

  • init_settings (PydanticBaseSettingsSource)

  • env_settings (PydanticBaseSettingsSource)

  • dotenv_settings (PydanticBaseSettingsSource)

  • file_secret_settings (PydanticBaseSettingsSource)

Return type:

tuple[PydanticBaseSettingsSource, ...]

make_manager(logger=None, *, kafka_broker=None)#

Construct an EventManager.

Parameters:
  • logger (BoundLogger | None, default: None) – Logger to use for internal logging. If not given, the safir.metrics logger will be used.

  • kafka_broker (KafkaBroker | None, default: None) – Kafka broker to use. If not given, a new Kafka broker will be created and automatically closed when the event manager is closed. If a broker is provided, closing the event manager will have no effect on it and the caller is responsible for starting and closing it.

Returns:

An event manager appropriate to the configuration.

Return type:

MockEventManager