Skip to main content
Version: 1.0.0

Metrics

A simulation wouldn't be worth doing if it's just a black box that doesn't output anything. The main method for outputting in V1 is Metrics. The Metric system has been designed with a few prebuild methods that can be turned on and configured to collect at certain steps. But mainly allows the creator of the simulation to collect data themselves by coding it into the code sections of the simulation configuration.

Each section of the code section gets the metric_collector class provided. This class can be used to collect metrics using the collect function. This function takes two arguments:

  • metric_name which is the name of the metric that you're trying to log.
  • arguments which is an object of arguments.
metric_collector.collect('balance', {'value': 100000, 'token': 'ETH', 'address': '0x6429FEe053768Ffa90a59cAfb98Ca9E8F6471211'})

This will add a structured log entry to the log file which will available for you to download at the end of the simulation. The log entry when calling it like this in your custom code will automatically populate some other fields about the current environment step and when the metric was collected. The amount of arguments here is unlimited, feel free to add as much data as you'd like.

Prebuild

Currently there are two prebuild metric collectors. These will be collected at a certain runsOn. The runsOn argument is optional, if not provided and the metric is enabled it will collect at all supported steps.

balance

Balance will add a log entry with the blanace of an agent for every token that is currently configured (see the tokens section).

Supported runsOn:

  • agentInitialization
  • agentPreStep
  • agentStep
  • agentPostStep

step_action:

Will log which step has been performed by the agent in a very raw format. You might want to do this yourself and add more detailed information.

Supported runsOn:

  • agentStep

Format

nametype
typeobject
requiredtrue

Example

metrics:
prebuild:
balance:
enabled: true
runsOn: ["agentPreStep"]
step_action:
enabled: true
runsOn: ["agentStep"]