class documentation

class Statistics(object):

View In Hierarchy

Statistics class. Handles all internal statistics.

Method configure Configure the statistics plugin. This is called when the configuration is loaded or reloaded.
Method initStatistics Initialize the statistics plugin.
Method purgeDBStatistics Purge statistics data.
Method restart Reset the statistics data.
Method retrieveDBStatistics Retrieve statistics data.
Method setupStats Setup the statistics dictionary.
Method start Start the statistics plugin. This includes subscribing to events and starting the background worker for writing statistics to the database.
Method statisticsDBWorker Background worker to write statistics to the database.
Method statsAsDict Return the current statistics as a dictionary.
Method stop Shutdown the statistics service.
Method storeDBStatistics Store statistics data.
Method validate Validate the configuration for the statistics plugin.
Class Variable __slots__ Slots of class attributes.
Class Variable storage Injected Storage instance.
Instance Variable statLock Lock for statistic handling.
Instance Variable stats Statistics records.
Method _handleStatsEvent Generic handling of statist events.
def configure(self, config: Configuration):

Configure the statistics plugin. This is called when the configuration is loaded or reloaded.

Parameters
config:ConfigurationThe configuration object.
@init
def initStatistics(self):

Initialize the statistics plugin.

def purgeDBStatistics(self):

Purge statistics data.

def restart(self):

Reset the statistics data.

def retrieveDBStatistics(self) -> StatsT:

Retrieve statistics data.

Returns
StatsTThe retrieved statistics dictionary.
def setupStats(self) -> StatsT:

Setup the statistics dictionary.

Returns
StatsTThe statistics dictionary.
def start(self):

Start the statistics plugin. This includes subscribing to events and starting the background worker for writing statistics to the database.

def statisticsDBWorker(self) -> bool:

Background worker to write statistics to the database.

Returns
boolTrue if the statistics were written successfully, False otherwise. True continous the worker.
def statsAsDict(self) -> dict[str, JSON]:

Return the current statistics as a dictionary.

Returns: A dictionary containing the current statistics.

def stop(self) -> bool:

Shutdown the statistics service.

Returns
boolTrue if shutdown was successful, False otherwise.
def storeDBStatistics(self) -> bool:

Store statistics data.

Returns
boolTrue if the statistics were stored successfully, False otherwise.
def validate(self, config: Configuration):

Validate the configuration for the statistics plugin.

Parameters
config:ConfigurationThe configuration object.
__slots__: tuple[str, ...] =

Slots of class attributes.

storage: Storage =

Injected Storage instance.

statLock =

Lock for statistic handling.

stats =

Statistics records.

def _handleStatsEvent(self, eventType: str):

Generic handling of statist events.

Parameters
eventType:strThe event short name as a string. The event name is used to identify the statistic to update.