1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:39:01 +01:00
This commit is contained in:
Daniil Gentili 2024-05-09 21:06:07 +02:00
parent 746d88b852
commit 642e7d5dfa
4 changed files with 55 additions and 14 deletions

View File

@ -2301,9 +2301,6 @@
<MixedMethodCall>
<code><![CDATA[disconnect]]></code>
</MixedMethodCall>
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$API->getPromGauge("", "ipc_server_connections", "Number of IPC server connections")]]></code>
</PossiblyNullPropertyAssignmentValue>
<PropertyNotSetInConstructor>
<code><![CDATA[$callback]]></code>
<code><![CDATA[$server]]></code>
@ -3320,9 +3317,6 @@
<code><![CDATA[$this->authorization['user']['bot']]]></code>
<code><![CDATA[$this->authorization['user']['id']]]></code>
</PossiblyNullArrayAccess>
<PossiblyNullPropertyAssignmentValue>
<code><![CDATA[$this->getPromCounter("", "update_count", "Number of received updates since the session was created")]]></code>
</PossiblyNullPropertyAssignmentValue>
<PossiblyNullReference>
<code><![CDATA[init]]></code>
<code><![CDATA[saveDbProperties]]></code>
@ -3656,7 +3650,7 @@
</MixedOperand>
<PossiblyInvalidArgument>
<code><![CDATA[$response]]></code>
<code><![CDATA[time() + $seconds]]></code>
<code><![CDATA[hrtime(true) + ($seconds * 1_000_000_000)]]></code>
</PossiblyInvalidArgument>
<PossiblyNullArgument>
<code><![CDATA[$msgId]]></code>
@ -3665,6 +3659,10 @@
<code><![CDATA[$msgId]]></code>
<code><![CDATA[$request->getMsgId()]]></code>
</PossiblyNullArgument>
<PossiblyNullOperand>
<code><![CDATA[$request->getSent()]]></code>
<code><![CDATA[$request->getSent()]]></code>
</PossiblyNullOperand>
<RedundantConditionGivenDocblockType>
<code><![CDATA[$this->API->authorized_dc == $this->datacenter && $this->API->authorized === \danog\MadelineProto\API::LOGGED_IN]]></code>
</RedundantConditionGivenDocblockType>
@ -4509,8 +4507,6 @@
<code><![CDATA[$total_count]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$entity['_']]]></code>
<code><![CDATA[$entity['user_id']]]></code>
<code><![CDATA[$full['full']['chat_photo']]]></code>
<code><![CDATA[$full['full']['chat_photo']]]></code>
<code><![CDATA[$full['full']['exported_invite']]]></code>

View File

@ -279,10 +279,10 @@ trait ResponseHandler
$this->requestResponse->inc([
'method' => $request->constructor,
'error_message' => 'OK',
'error_code' => '200'
'error_code' => '200',
]);
$this->requestLatencies?->observe(
hrtime(true) - $request->getSent(),
(hrtime(true) - $request->getSent()) / 1_000_000_000.0,
['method' => $request->constructor]
);
}
@ -299,10 +299,10 @@ trait ResponseHandler
$this->requestResponse->inc([
'method' => $request->constructor,
'error_message' => preg_replace('/\d+/', 'X', $response['error_message']),
'error_code' => (string) $response['error_code']
'error_code' => (string) $response['error_code'],
]);
$this->requestLatencies?->observe(
hrtime(true) - $request->getSent(),
(hrtime(true) - $request->getSent()) / 1_000_000_000.0,
['method' => $request->constructor]
);
}

View File

@ -0,0 +1,45 @@
<?php declare(strict_types=1);
/**
* This file is part of MadelineProto.
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <daniil@daniil.it>
* @copyright 2016-2023 Daniil Gentili <daniil@daniil.it>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/
namespace danog\MadelineProto\Settings;
use danog\MadelineProto\SettingsAbstract;
/**
* Prometheus settings.
*/
final class Prometheus extends SettingsAbstract
{
/**
* Whether to enable prometheus stat reporting for this session.
*/
protected bool $enablePrometheus = false;
/**
* Whether to enable additional prometheus stat reporting for this session.
*/
public function setEnablePrometheus(bool $enable): self
{
$this->enablePrometheus = $enable;
return $this;
}
/**
* Whether additional prometheus stat reporting is enabled for this session.
*/
public function getEnablePrometheus(): bool
{
return $this->enablePrometheus;
}
}