Hello,
we are currently implementing some metrics, but i can't get the tenant usage to work as i would expect it.
Click the "refresh" button in the products/services tab on the clients details page. The tenantUsage function is called with the expected tenant (i use a custom field here). But when I populate a metric with a Usage using Metric->withUsage(), the Metric object holds a "NoUsage" Object afterwards.
I tried with different Metrics using different units and periods. I tried explicitly setting the from, to and collectedAt dates when instantiating the Usage. I tried passing different values into the Usage constructor - no success. The tbltenant_stats entry is updated with the new updated_at time, but the value remains 0.000. The table in the admins frontend also reads "-" where i would expect the updated usage values.
Here is some minimal example:
public function metrics()
{
return [
new Metric(
'mymetric',
'My metric',
MetricInterface::TYPE_PERIOD_MONTH,
new KiloBytes()
)
]
}
public function tenantUsage($tenant)
{
$metric = current($this->metrics());
$usage = new Usage(123.4); //$usage holds the value as expected
$populatedMetric = $metric->withUsage($usage); //$populatedMetric now holds an instance of NoUsage
$controlUsage = $usageMetric->usage(); //control usage is instanceof NoUsage
return $usage;
}