Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 9c41cf3

Browse files
committed
Collect metrics only if statistics are enabled.
1 parent 81ee07f commit 9c41cf3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/API/TriggerEvent.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public function __invoke(Request $request)
4949
$request->appId, $request->socket_id, $channelName, (object) $payload
5050
);
5151

52-
StatisticsCollector::apiMessage($request->appId);
52+
if ($this->app->statisticsEnabled) {
53+
StatisticsCollector::apiMessage($request->appId);
54+
}
5355

5456
DashboardLogger::log($request->appId, DashboardLogger::TYPE_API_MESSAGE, [
5557
'event' => $request->name,

src/Server/WebSocketHandler.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public function onOpen(ConnectionInterface $connection)
5656
/** @var \GuzzleHttp\Psr7\Request $request */
5757
$request = $connection->httpRequest;
5858

59-
StatisticsCollector::connection($connection->app->id);
59+
if ($connection->app->statisticsEnabled) {
60+
StatisticsCollector::connection($connection->app->id);
61+
}
6062

6163
$this->channelManager->subscribeToApp($connection->app->id);
6264

@@ -88,7 +90,9 @@ public function onMessage(ConnectionInterface $connection, MessageInterface $mes
8890
$message, $connection, $this->channelManager
8991
)->respond();
9092

91-
StatisticsCollector::webSocketMessage($connection->app->id);
93+
if ($connection->app->statisticsEnabled) {
94+
StatisticsCollector::webSocketMessage($connection->app->id);
95+
}
9296

9397
WebSocketMessageReceived::dispatch(
9498
$connection->app->id,
@@ -109,7 +113,9 @@ public function onClose(ConnectionInterface $connection)
109113
->unsubscribeFromAllChannels($connection)
110114
->then(function (bool $unsubscribed) use ($connection) {
111115
if (isset($connection->app)) {
112-
StatisticsCollector::disconnection($connection->app->id);
116+
if ($connection->app->statisticsEnabled) {
117+
StatisticsCollector::disconnection($connection->app->id);
118+
}
113119

114120
$this->channelManager->unsubscribeFromApp($connection->app->id);
115121

0 commit comments

Comments
 (0)