Интегрирован сбор метрик в sessionserver

This commit is contained in:
ErickSkrauch
2017-11-19 15:36:51 +03:00
parent 72f546c827
commit 236f0e7d50
2 changed files with 16 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ use api\modules\session\exceptions\IllegalArgumentException;
use api\modules\session\models\protocols\HasJoinedInterface;
use api\modules\session\Module as Session;
use common\models\Account;
use Yii;
use yii\base\ErrorException;
use yii\base\Model;
@@ -19,6 +20,7 @@ class HasJoinedForm extends Model {
}
public function hasJoined(): Account {
Yii::$app->statsd->inc('sessionserver.hasJoined.attempt');
if (!$this->protocol->validate()) {
throw new IllegalArgumentException();
}
@@ -26,13 +28,12 @@ class HasJoinedForm extends Model {
$serverId = $this->protocol->getServerId();
$username = $this->protocol->getUsername();
Session::info(
"Server with server_id = '{$serverId}' trying to verify has joined user with username = '{$username}'."
);
Session::info("Server with server_id = '{$serverId}' trying to verify has joined user with username = '{$username}'.");
$joinModel = SessionModel::find($username, $serverId);
if ($joinModel === null) {
Session::error("Not found join operation for username = '{$username}'.");
Yii::$app->statsd->inc('sessionserver.hasJoined.fail_no_join');
throw new ForbiddenOperationException('Invalid token.');
}
@@ -42,9 +43,8 @@ class HasJoinedForm extends Model {
throw new ErrorException('Account must exists');
}
Session::info(
"User with username = '{$username}' successfully verified by server with server_id = '{$serverId}'."
);
Session::info("User with username = '{$username}' successfully verified by server with server_id = '{$serverId}'.");
Yii::$app->statsd->inc('sessionserver.hasJoined.success');
return $account;
}