babylon.metrics.models

SQLAlchemy models for metrics persistence.

These models store the historical record of the simulation’s performance and state metrics in the Ledger (SQLite).

Classes

Counter(**kwargs)

A counter metric that only increases.

Metric(**kwargs)

A single metric measurement stored in the database.

MetricsBase(**kwargs)

Base class for metrics models.

TimeSeries(**kwargs)

Time-series data point for dashboard visualization.

class babylon.metrics.models.MetricsBase(**kwargs)[source]

Bases: DeclarativeBase

Base class for metrics models. Separate from main app to avoid circular imports.

Parameters:

kwargs (Any)

__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

Parameters:
Return type:

None

metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

See also

orm_declarative_metadata

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class babylon.metrics.models.Metric(**kwargs)[source]

Bases: MetricsBase

A single metric measurement stored in the database.

This is the materialized form of MetricEvent, persisted to SQLite for historical analysis and dashboard rendering.

id: Mapped[int]
name: Mapped[str]
value: Mapped[float]
timestamp: Mapped[datetime]
tags: Mapped[str | None]
extra_data: Mapped[str | None]
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class babylon.metrics.models.Counter(**kwargs)[source]

Bases: MetricsBase

A counter metric that only increases.

Used for tracking cumulative counts like total events processed, total embeddings generated, etc.

id: Mapped[int]
name: Mapped[str]
value: Mapped[int]
last_updated: Mapped[datetime | None]
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

class babylon.metrics.models.TimeSeries(**kwargs)[source]

Bases: MetricsBase

Time-series data point for dashboard visualization.

Optimized for time-range queries and charting. This is where the simulation’s history is recorded for player dashboards.

id: Mapped[int]
tick: Mapped[int]
metric: Mapped[str]
value: Mapped[float]
region: Mapped[str | None]
timestamp: Mapped[datetime]
__init__(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.