getMethod()->getAnnotation(CollectModelMetrics::class); $prefix = trim($annotation->prefix, '.'); Yii::$app->statsd->inc($prefix . '.attempt'); $result = $invocation->proceed(); if ($result !== false) { Yii::$app->statsd->inc($prefix . '.success'); return $result; } /** @var \yii\base\Model $model */ $model = $invocation->getThis(); $errors = array_values($model->getFirstErrors()); if (!isset($errors[0])) { Yii::error('Unsuccess result with empty errors list'); return false; } Yii::$app->statsd->inc($prefix . '.' . $errors[0]); return false; } }