mirror of
https://github.com/elyby/accounts.git
synced 2024-11-27 01:02:06 +05:30
Улучшено логгирование метрик в statsd
This commit is contained in:
parent
e3a99f04fe
commit
c6d18f49e7
@ -126,8 +126,8 @@ class OauthProcess {
|
|||||||
/**
|
/**
|
||||||
* Метод выполняется сервером приложения, которому был выдан auth_token или refresh_token.
|
* Метод выполняется сервером приложения, которому был выдан auth_token или refresh_token.
|
||||||
*
|
*
|
||||||
* Входными данными является стандартный список GET параметров по стандарту oAuth:
|
* Входными данными является стандартный список POST параметров по стандарту oAuth:
|
||||||
* $_GET = [
|
* $_POST = [
|
||||||
* client_id,
|
* client_id,
|
||||||
* client_secret,
|
* client_secret,
|
||||||
* redirect_uri,
|
* redirect_uri,
|
||||||
@ -135,7 +135,7 @@ class OauthProcess {
|
|||||||
* grant_type,
|
* grant_type,
|
||||||
* ]
|
* ]
|
||||||
* для запроса grant_type = authentication_code.
|
* для запроса grant_type = authentication_code.
|
||||||
* $_GET = [
|
* $_POST = [
|
||||||
* client_id,
|
* client_id,
|
||||||
* client_secret,
|
* client_secret,
|
||||||
* refresh_token,
|
* refresh_token,
|
||||||
@ -145,12 +145,15 @@ class OauthProcess {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getToken(): array {
|
public function getToken(): array {
|
||||||
|
$grantType = Yii::$app->request->post('grant_type', 'null');
|
||||||
try {
|
try {
|
||||||
Yii::$app->statsd->inc('oauth.issueToken.attempt');
|
Yii::$app->statsd->inc("oauth.issueToken_{$grantType}.attempt");
|
||||||
$response = $this->server->issueAccessToken();
|
$response = $this->server->issueAccessToken();
|
||||||
Yii::$app->statsd->inc('oauth.issueToken.success');
|
$clientId = Yii::$app->request->post('client_id');
|
||||||
|
Yii::$app->statsd->inc("oauth.issueToken_client.{$clientId}");
|
||||||
|
Yii::$app->statsd->inc("oauth.issueToken_{$grantType}.success");
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthException $e) {
|
||||||
Yii::$app->statsd->inc('oauth.issueToken.fail');
|
Yii::$app->statsd->inc("oauth.issueToken_{$grantType}.fail");
|
||||||
Yii::$app->response->statusCode = $e->httpStatusCode;
|
Yii::$app->response->statusCode = $e->httpStatusCode;
|
||||||
$response = [
|
$response = [
|
||||||
'error' => $e->errorType,
|
'error' => $e->errorType,
|
||||||
|
@ -53,7 +53,7 @@ class JoinForm extends Model {
|
|||||||
$serverId = $this->serverId;
|
$serverId = $this->serverId;
|
||||||
$accessToken = $this->accessToken;
|
$accessToken = $this->accessToken;
|
||||||
Session::info("User with access_token = '{$accessToken}' trying join to server with server_id = '{$serverId}'.");
|
Session::info("User with access_token = '{$accessToken}' trying join to server with server_id = '{$serverId}'.");
|
||||||
Yii::$app->statsd->inc('sessionserver.join.attempts');
|
Yii::$app->statsd->inc('sessionserver.join.attempt');
|
||||||
if (!$this->validate()) {
|
if (!$this->validate()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace common\tasks;
|
|||||||
use common\emails\EmailHelper;
|
use common\emails\EmailHelper;
|
||||||
use common\emails\templates\ChangeEmailConfirmCurrentEmail;
|
use common\emails\templates\ChangeEmailConfirmCurrentEmail;
|
||||||
use common\models\confirmations\CurrentEmailConfirmation;
|
use common\models\confirmations\CurrentEmailConfirmation;
|
||||||
|
use Yii;
|
||||||
use yii\queue\RetryableJobInterface;
|
use yii\queue\RetryableJobInterface;
|
||||||
|
|
||||||
class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
||||||
@ -36,6 +37,7 @@ class SendCurrentEmailConfirmation implements RetryableJobInterface {
|
|||||||
* @param \yii\queue\Queue $queue
|
* @param \yii\queue\Queue $queue
|
||||||
*/
|
*/
|
||||||
public function execute($queue) {
|
public function execute($queue) {
|
||||||
|
Yii::$app->statsd->inc('queue.sendCurrentEmailConfirmation.attempt');
|
||||||
$to = EmailHelper::buildTo($this->username, $this->email);
|
$to = EmailHelper::buildTo($this->username, $this->email);
|
||||||
$template = new ChangeEmailConfirmCurrentEmail($to, $this->code);
|
$template = new ChangeEmailConfirmCurrentEmail($to, $this->code);
|
||||||
$template->send();
|
$template->send();
|
||||||
|
@ -5,6 +5,7 @@ namespace common\tasks;
|
|||||||
use common\emails\EmailHelper;
|
use common\emails\EmailHelper;
|
||||||
use common\emails\templates\ChangeEmailConfirmNewEmail;
|
use common\emails\templates\ChangeEmailConfirmNewEmail;
|
||||||
use common\models\confirmations\NewEmailConfirmation;
|
use common\models\confirmations\NewEmailConfirmation;
|
||||||
|
use Yii;
|
||||||
use yii\queue\RetryableJobInterface;
|
use yii\queue\RetryableJobInterface;
|
||||||
|
|
||||||
class SendNewEmailConfirmation implements RetryableJobInterface {
|
class SendNewEmailConfirmation implements RetryableJobInterface {
|
||||||
@ -36,6 +37,7 @@ class SendNewEmailConfirmation implements RetryableJobInterface {
|
|||||||
* @param \yii\queue\Queue $queue
|
* @param \yii\queue\Queue $queue
|
||||||
*/
|
*/
|
||||||
public function execute($queue) {
|
public function execute($queue) {
|
||||||
|
Yii::$app->statsd->inc('queue.sendNewEmailConfirmation.attempt');
|
||||||
$to = EmailHelper::buildTo($this->username, $this->email);
|
$to = EmailHelper::buildTo($this->username, $this->email);
|
||||||
$template = new ChangeEmailConfirmNewEmail($to, $this->username, $this->code);
|
$template = new ChangeEmailConfirmNewEmail($to, $this->username, $this->code);
|
||||||
$template->send();
|
$template->send();
|
||||||
|
@ -47,6 +47,7 @@ class SendPasswordRecoveryEmail implements RetryableJobInterface {
|
|||||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||||
*/
|
*/
|
||||||
public function execute($queue) {
|
public function execute($queue) {
|
||||||
|
Yii::$app->statsd->inc('queue.sendPasswordRecovery.attempt');
|
||||||
$params = new ForgotPasswordParams($this->username, $this->code, $this->link);
|
$params = new ForgotPasswordParams($this->username, $this->code, $this->link);
|
||||||
$to = EmailHelper::buildTo($this->username, $this->email);
|
$to = EmailHelper::buildTo($this->username, $this->email);
|
||||||
$template = new ForgotPasswordEmail($to, $this->locale, $params);
|
$template = new ForgotPasswordEmail($to, $this->locale, $params);
|
||||||
|
@ -47,6 +47,7 @@ class SendRegistrationEmail implements RetryableJobInterface {
|
|||||||
* @throws \common\emails\exceptions\CannotSendEmailException
|
* @throws \common\emails\exceptions\CannotSendEmailException
|
||||||
*/
|
*/
|
||||||
public function execute($queue) {
|
public function execute($queue) {
|
||||||
|
Yii::$app->statsd->inc('queue.sendRegistrationEmail.attempt');
|
||||||
$params = new RegistrationEmailParams($this->username, $this->code, $this->link);
|
$params = new RegistrationEmailParams($this->username, $this->code, $this->link);
|
||||||
$to = EmailHelper::buildTo($this->username, $this->email);
|
$to = EmailHelper::buildTo($this->username, $this->email);
|
||||||
$template = new RegistrationEmail($to, $this->locale, $params);
|
$template = new RegistrationEmail($to, $this->locale, $params);
|
||||||
|
Loading…
Reference in New Issue
Block a user