mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
addressed comments
This commit is contained in:
@@ -62,6 +62,7 @@ class Screenshots extends Action
|
||||
Console::log('Screenshot action started');
|
||||
|
||||
$payload = $message->getPayload() ?? [];
|
||||
$screenshotCompleted = false;
|
||||
|
||||
if (empty($payload)) {
|
||||
throw new \Exception('Missing payload');
|
||||
@@ -262,13 +263,7 @@ class Screenshots extends Action
|
||||
'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''),
|
||||
'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''),
|
||||
]));
|
||||
|
||||
$this->publishUsage(
|
||||
project: $project,
|
||||
site: $site,
|
||||
publisherForUsage: $publisherForUsage,
|
||||
metric: METRIC_SCREENSHOTS_SUCCESS
|
||||
);
|
||||
$screenshotCompleted = true;
|
||||
} catch (\Throwable $th) {
|
||||
Console::warning("Screenshot failed to generate:");
|
||||
Console::warning($th->getMessage());
|
||||
@@ -277,15 +272,24 @@ class Screenshots extends Action
|
||||
$date = \date('H:i:s');
|
||||
$this->appendToLogs($dbForProject, $deployment->getId(), $queueForRealtime, "[90m[$date] [90m[[0mappwrite[90m][33m Screenshot capturing failed. Deployment will continue. [0m\n");
|
||||
|
||||
$this->publishUsage(
|
||||
project: $project,
|
||||
site: $site,
|
||||
publisherForUsage: $publisherForUsage,
|
||||
metric: METRIC_SCREENSHOTS_FAILED
|
||||
);
|
||||
if (!$screenshotCompleted) {
|
||||
$this->publishUsage(
|
||||
project: $project,
|
||||
site: $site,
|
||||
publisherForUsage: $publisherForUsage,
|
||||
metric: METRIC_SCREENSHOTS_FAILED
|
||||
);
|
||||
}
|
||||
|
||||
throw $th;
|
||||
}
|
||||
|
||||
$this->publishUsage(
|
||||
project: $project,
|
||||
site: $site,
|
||||
publisherForUsage: $publisherForUsage,
|
||||
metric: METRIC_SCREENSHOTS_SUCCESS
|
||||
);
|
||||
}
|
||||
|
||||
protected function publishUsage(
|
||||
|
||||
@@ -10,6 +10,38 @@ class UsageSite extends UsageFunction
|
||||
{
|
||||
parent::__construct();
|
||||
$this
|
||||
->addRule('screenshotsSuccessTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of successful site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsFailedTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of failed site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccessRate', [
|
||||
'type' => self::TYPE_FLOAT,
|
||||
'description' => 'Success rate of site screenshots from 0 to 1.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccess', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of successful site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsFailed', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of failed site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('requestsTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of requests.',
|
||||
@@ -49,38 +81,6 @@ class UsageSite extends UsageFunction
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsSuccessTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of successful site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsFailedTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of failed site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccessRate', [
|
||||
'type' => self::TYPE_FLOAT,
|
||||
'description' => 'Success rate of site screenshots from 0 to 1.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccess', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of successful site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsFailed', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of failed site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,36 @@ class UsageSites extends Model
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('buildsSuccessTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of successful site builds.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('buildsFailedTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of failed site builds.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccessTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of successful site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsFailedTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of failed site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccessRate', [
|
||||
'type' => self::TYPE_FLOAT,
|
||||
'description' => 'Success rate of site screenshots from 0 to 1.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('requestsTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of requests.',
|
||||
@@ -122,38 +152,6 @@ class UsageSites extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsSuccessTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of successful site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsFailedTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of failed site screenshots.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccessRate', [
|
||||
'type' => self::TYPE_FLOAT,
|
||||
'description' => 'Success rate of site screenshots from 0 to 1.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('screenshotsSuccess', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of successful site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsFailed', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of failed site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('deployments', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of sites deployment per period.',
|
||||
@@ -168,18 +166,6 @@ class UsageSites extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('buildsSuccessTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of successful site builds.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('buildsFailedTotal', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Total aggregated number of failed site builds.',
|
||||
'default' => 0,
|
||||
'example' => 0,
|
||||
])
|
||||
->addRule('builds', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of sites build per period.',
|
||||
@@ -208,6 +194,34 @@ class UsageSites extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('buildsSuccess', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of successful site builds per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('buildsFailed', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of failed site builds per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsSuccess', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of successful site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('screenshotsFailed', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of failed site screenshots per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('executions', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of sites execution per period.',
|
||||
@@ -229,20 +243,6 @@ class UsageSites extends Model
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('buildsSuccess', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of successful site builds per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
->addRule('buildsFailed', [
|
||||
'type' => Response::MODEL_METRIC,
|
||||
'description' => 'Aggregated number of failed site builds per period.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user