EventMetadata#

pydantic model safir.metrics.EventMetadata#

Common fields for all metrics events.

Contains the minimum required fields. This gets mixed in to a class also containing event payload fields, and then gets shipped to Kafka, by the EventManager

Parameters:

data (Any)

Fields:
field application: str [Required]#

The application generating this event.

field id: Annotated[UUID] [Required]#

A globally unique value that identifies this event

Constraints:
  • uuid_version = 4

field timestamp: AwareDatetime [Required]#

The time at which this event occurred, or the time at which this event completed if it is a duration event.

field timestamp_ns: int [Required]#

The number of nanoseconds since the unix epoch. This is used as the InfluxDB timestamp.

asdict()#

Returns this model in dictionary form. This method differs from pydantic’s dict by converting all values to their Avro representation. It also doesn’t provide the exclude, include, by_alias, etc. parameters that dict provides.

Return type:

Dict[str, Any]

classmethod fake(**data)#

Creates a fake instance of the model.

Attributes:

data: Dict[str, Any] represent the user values to use in the instance

Parameters:

data (Any)

Return type:

AvroBaseModel

classmethod json_schema(*args, **kwargs)#
Parameters:
Return type:

str

serialize(serialization_type='avro')#

Overrides the base AvroModel’s serialize method to inject this class’s standardization factory method

Parameters:

serialization_type (Literal['avro', 'avro-json'], default: 'avro')

Return type:

bytes

to_dict()#
Return type:

Dict[str, Any]

validate_avro()#

Validate that instance matches the avro schema

Return type:

bool