register_tracer_factory

passengersim.callbacks.register_tracer_factory(cls: type[GenericTracer], *, parameters_model: type[BaseModel] | None = None, version: str | None = None, name: str | None = None) → None[source]

Register a tracer using the configuration it declares on its class.

register_tracer() does the same and also works as a class decorator; it is the preferred spelling.

The output name, options model, and version are read from the class attributes name, options_model, and options_version, and the hooks from the on_<hook> methods the class overrides or, for a legacy tracer, its hook attribute (see GenericTracer). They are defined once, beside the tracer’s constructor.

Parameters:
cls : type[GenericTracer]

Tracer class declaring a canonical name, and either hook methods or a hook.

parameters_model : type[pydantic.BaseModel] or None, optional

Overrides cls.options_model. Fields map to constructor keyword arguments. If neither is given, a model is derived from the constructor’s signature (see options_model_from_signature()).

version : str or None, optional

Overrides cls.options_version, the implementation version checked against explicit YAML requirements.

name : str or None, optional

Registry name or alias; defaults to cls.name. The configuration’s declaration ID names each result table.

Raises:
  • TypeError – If cls is not a GenericTracer subclass, or no options model is declared or given and none can be derived from the constructor.

  • ValueError – If registration duplicates a name, the class declares no hook, or it declares an invalid hook or output.