Merge remote-tracking branch 'origin/1.6.x' into feat-logs-db

This commit is contained in:
Damodar Lohani
2025-01-28 02:11:01 +00:00
13 changed files with 316 additions and 16 deletions
@@ -6361,6 +6361,7 @@
"gif",
"png",
"webp",
"heic",
"avif"
],
"x-enum-name": "ImageFormat",
+100 -3
View File
@@ -25157,6 +25157,7 @@
"gif",
"png",
"webp",
"heic",
"avif"
],
"x-enum-name": "ImageFormat",
@@ -35706,6 +35707,18 @@
"x-example": 0,
"format": "int32"
},
"databasesReadsTotal": {
"type": "integer",
"description": "Total number of databases reads.",
"x-example": 0,
"format": "int32"
},
"databasesWritesTotal": {
"type": "integer",
"description": "Total number of databases writes.",
"x-example": 0,
"format": "int32"
},
"databases": {
"type": "array",
"description": "Aggregated number of databases per period.",
@@ -35737,6 +35750,22 @@
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"databasesReads": {
"type": "array",
"description": "An array of aggregated number of database reads.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"databasesWrites": {
"type": "array",
"description": "An array of aggregated number of database writes.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
@@ -35745,10 +35774,14 @@
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databasesReadsTotal",
"databasesWritesTotal",
"databases",
"collections",
"documents",
"storage"
"storage",
"databasesReads",
"databasesWrites"
]
},
"usageDatabase": {
@@ -35778,6 +35811,18 @@
"x-example": 0,
"format": "int32"
},
"databaseReadsTotal": {
"type": "integer",
"description": "Total number of databases reads.",
"x-example": 0,
"format": "int32"
},
"databaseWritesTotal": {
"type": "integer",
"description": "Total number of databases writes.",
"x-example": 0,
"format": "int32"
},
"collections": {
"type": "array",
"description": "Aggregated number of collections per period.",
@@ -35801,6 +35846,22 @@
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"databaseReads": {
"type": "array",
"description": "An array of aggregated number of database reads.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"databaseWrites": {
"type": "array",
"description": "An array of aggregated number of database writes.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
@@ -35808,9 +35869,13 @@
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databaseReadsTotal",
"databaseWritesTotal",
"collections",
"documents",
"storage"
"storage",
"databaseReads",
"databaseWrites"
]
},
"usageCollection": {
@@ -36405,6 +36470,18 @@
"x-example": 0,
"format": "int32"
},
"databasesReadsTotal": {
"type": "integer",
"description": "Total number of databases reads.",
"x-example": 0,
"format": "int32"
},
"databasesWritesTotal": {
"type": "integer",
"description": "Total number of databases writes.",
"x-example": 0,
"format": "int32"
},
"requests": {
"type": "array",
"description": "Aggregated number of requests per period.",
@@ -36504,6 +36581,22 @@
"$ref": "#\/components\/schemas\/metricBreakdown"
},
"x-example": []
},
"databasesReads": {
"type": "array",
"description": "An array of aggregated number of database reads.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
},
"databasesWrites": {
"type": "array",
"description": "An array of aggregated number of database writes.",
"items": {
"$ref": "#\/components\/schemas\/metric"
},
"x-example": []
}
},
"required": [
@@ -36519,6 +36612,8 @@
"bucketsTotal",
"executionsMbSecondsTotal",
"buildsMbSecondsTotal",
"databasesReadsTotal",
"databasesWritesTotal",
"requests",
"network",
"users",
@@ -36531,7 +36626,9 @@
"functionsStorageBreakdown",
"authPhoneTotal",
"authPhoneEstimate",
"authPhoneCountryBreakdown"
"authPhoneCountryBreakdown",
"databasesReads",
"databasesWrites"
]
},
"headers": {
@@ -17577,6 +17577,7 @@
"gif",
"png",
"webp",
"heic",
"avif"
],
"x-enum-name": "ImageFormat",
@@ -6560,6 +6560,7 @@
"gif",
"png",
"webp",
"heic",
"avif"
],
"x-enum-name": "ImageFormat",
+106 -3
View File
@@ -25633,6 +25633,7 @@
"gif",
"png",
"webp",
"heic",
"avif"
],
"x-enum-name": "ImageFormat",
@@ -36243,6 +36244,18 @@
"x-example": 0,
"format": "int32"
},
"databasesReadsTotal": {
"type": "integer",
"description": "Total number of databases reads.",
"x-example": 0,
"format": "int32"
},
"databasesWritesTotal": {
"type": "integer",
"description": "Total number of databases writes.",
"x-example": 0,
"format": "int32"
},
"databases": {
"type": "array",
"description": "Aggregated number of databases per period.",
@@ -36278,6 +36291,24 @@
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"databasesReads": {
"type": "array",
"description": "An array of aggregated number of database reads.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"databasesWrites": {
"type": "array",
"description": "An array of aggregated number of database writes.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
@@ -36286,10 +36317,14 @@
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databasesReadsTotal",
"databasesWritesTotal",
"databases",
"collections",
"documents",
"storage"
"storage",
"databasesReads",
"databasesWrites"
]
},
"usageDatabase": {
@@ -36319,6 +36354,18 @@
"x-example": 0,
"format": "int32"
},
"databaseReadsTotal": {
"type": "integer",
"description": "Total number of databases reads.",
"x-example": 0,
"format": "int32"
},
"databaseWritesTotal": {
"type": "integer",
"description": "Total number of databases writes.",
"x-example": 0,
"format": "int32"
},
"collections": {
"type": "array",
"description": "Aggregated number of collections per period.",
@@ -36345,6 +36392,24 @@
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"databaseReads": {
"type": "array",
"description": "An array of aggregated number of database reads.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"databaseWrites": {
"type": "array",
"description": "An array of aggregated number of database writes.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
@@ -36352,9 +36417,13 @@
"collectionsTotal",
"documentsTotal",
"storageTotal",
"databaseReadsTotal",
"databaseWritesTotal",
"collections",
"documents",
"storage"
"storage",
"databaseReads",
"databaseWrites"
]
},
"usageCollection": {
@@ -36976,6 +37045,18 @@
"x-example": 0,
"format": "int32"
},
"databasesReadsTotal": {
"type": "integer",
"description": "Total number of databases reads.",
"x-example": 0,
"format": "int32"
},
"databasesWritesTotal": {
"type": "integer",
"description": "Total number of databases writes.",
"x-example": 0,
"format": "int32"
},
"requests": {
"type": "array",
"description": "Aggregated number of requests per period.",
@@ -37086,6 +37167,24 @@
"$ref": "#\/definitions\/metricBreakdown"
},
"x-example": []
},
"databasesReads": {
"type": "array",
"description": "An array of aggregated number of database reads.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
},
"databasesWrites": {
"type": "array",
"description": "An array of aggregated number of database writes.",
"items": {
"type": "object",
"$ref": "#\/definitions\/metric"
},
"x-example": []
}
},
"required": [
@@ -37101,6 +37200,8 @@
"bucketsTotal",
"executionsMbSecondsTotal",
"buildsMbSecondsTotal",
"databasesReadsTotal",
"databasesWritesTotal",
"requests",
"network",
"users",
@@ -37113,7 +37214,9 @@
"functionsStorageBreakdown",
"authPhoneTotal",
"authPhoneEstimate",
"authPhoneCountryBreakdown"
"authPhoneCountryBreakdown",
"databasesReads",
"databasesWrites"
]
},
"headers": {
@@ -18034,6 +18034,7 @@
"gif",
"png",
"webp",
"heic",
"avif"
],
"x-enum-name": "ImageFormat",
+14 -2
View File
@@ -4185,7 +4185,9 @@ App::get('/v1/databases/usage')
METRIC_DATABASES,
METRIC_COLLECTIONS,
METRIC_DOCUMENTS,
METRIC_DATABASES_STORAGE
METRIC_DATABASES_STORAGE,
METRIC_DATABASES_OPERATIONS_READS,
METRIC_DATABASES_OPERATIONS_WRITES,
];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
@@ -4237,10 +4239,14 @@ App::get('/v1/databases/usage')
'collectionsTotal' => $usage[$metrics[1]]['total'],
'documentsTotal' => $usage[$metrics[2]]['total'],
'storageTotal' => $usage[$metrics[3]]['total'],
'databasesReadsTotal' => $usage[$metrics[4]]['total'],
'databasesWritesTotal' => $usage[$metrics[5]]['total'],
'databases' => $usage[$metrics[0]]['data'],
'collections' => $usage[$metrics[1]]['data'],
'documents' => $usage[$metrics[2]]['data'],
'storage' => $usage[$metrics[3]]['data'],
'databasesReads' => $usage[$metrics[4]]['data'],
'databasesWrites' => $usage[$metrics[5]]['data'],
]), Response::MODEL_USAGE_DATABASES);
});
@@ -4280,7 +4286,9 @@ App::get('/v1/databases/:databaseId/usage')
$metrics = [
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_COLLECTIONS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_DOCUMENTS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE)
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASE_ID_STORAGE),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_READS),
str_replace('{databaseInternalId}', $database->getInternalId(), METRIC_DATABASES_OPERATIONS_WRITES)
];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
@@ -4332,9 +4340,13 @@ App::get('/v1/databases/:databaseId/usage')
'collectionsTotal' => $usage[$metrics[0]]['total'],
'documentsTotal' => $usage[$metrics[1]]['total'],
'storageTotal' => $usage[$metrics[2]]['total'],
'databaseReadsTotal' => $usage[$metrics[3]]['total'],
'databaseWritesTotal' => $usage[$metrics[4]]['total'],
'collections' => $usage[$metrics[0]]['data'],
'documents' => $usage[$metrics[1]]['data'],
'storage' => $usage[$metrics[2]]['data'],
'databaseReads' => $usage[$metrics[3]]['data'],
'databaseWrites' => $usage[$metrics[4]]['data'],
]), Response::MODEL_USAGE_DATABASE);
});
+10 -4
View File
@@ -60,7 +60,9 @@ App::get('/v1/project/usage')
METRIC_FILES_STORAGE,
METRIC_DATABASES_STORAGE,
METRIC_DEPLOYMENTS_STORAGE,
METRIC_BUILDS_STORAGE
METRIC_BUILDS_STORAGE,
METRIC_DATABASES_OPERATIONS_READS,
METRIC_DATABASES_OPERATIONS_WRITES,
],
'period' => [
METRIC_NETWORK_REQUESTS,
@@ -70,7 +72,9 @@ App::get('/v1/project/usage')
METRIC_EXECUTIONS,
METRIC_DATABASES_STORAGE,
METRIC_EXECUTIONS_MB_SECONDS,
METRIC_BUILDS_MB_SECONDS
METRIC_BUILDS_MB_SECONDS,
METRIC_DATABASES_OPERATIONS_READS,
METRIC_DATABASES_OPERATIONS_WRITES,
]
];
@@ -346,10 +350,12 @@ App::get('/v1/project/usage')
'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE],
'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE],
'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE],
'databasesReadsTotal' => $total[METRIC_DATABASES_OPERATIONS_READS],
'databasesWritesTotal' => $total[METRIC_DATABASES_OPERATIONS_WRITES],
'executionsBreakdown' => $executionsBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
'bucketsBreakdown' => $bucketsBreakdown,
'databasesReads' => $usage[METRIC_DATABASES_OPERATIONS_READS],
'databasesWrites' => $usage[METRIC_DATABASES_OPERATIONS_WRITES],
'databasesStorageBreakdown' => $databasesStorageBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
@@ -34,6 +34,18 @@ class UsageDatabase extends Model
'default' => 0,
'example' => 0,
])
->addRule('databaseReadsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases reads.',
'default' => 0,
'example' => 0,
])
->addRule('databaseWritesTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases writes.',
'default' => 0,
'example' => 0,
])
->addRule('collections', [
'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of collections per period.',
@@ -55,6 +67,20 @@ class UsageDatabase extends Model
'example' => [],
'array' => true
])
->addRule('databaseReads', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database reads.',
'default' => [],
'example' => [],
'array' => true
])
->addRule('databaseWrites', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database writes.',
'default' => [],
'example' => [],
'array' => true
])
;
}
@@ -40,6 +40,18 @@ class UsageDatabases extends Model
'default' => 0,
'example' => 0,
])
->addRule('databasesReadsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases reads.',
'default' => 0,
'example' => 0,
])
->addRule('databasesWritesTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases writes.',
'default' => 0,
'example' => 0,
])
->addRule('databases', [
'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of databases per period.',
@@ -68,6 +80,20 @@ class UsageDatabases extends Model
'example' => [],
'array' => true
])
->addRule('databasesReads', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database reads.',
'default' => [],
'example' => [],
'array' => true
])
->addRule('databasesWrites', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database writes.',
'default' => [],
'example' => [],
'array' => true
])
;
}
@@ -82,6 +82,18 @@ class UsageProject extends Model
'default' => 0,
'example' => 0,
])
->addRule('databasesReadsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases reads.',
'default' => 0,
'example' => 0,
])
->addRule('databasesWritesTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of databases writes.',
'default' => 0,
'example' => 0,
])
->addRule('requests', [
'type' => Response::MODEL_METRIC,
'description' => 'Aggregated number of requests per period.',
@@ -171,6 +183,20 @@ class UsageProject extends Model
'example' => [],
'array' => true
])
->addRule('databasesReads', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database reads.',
'default' => [],
'example' => [],
'array' => true
])
->addRule('databasesWrites', [
'type' => Response::MODEL_METRIC,
'description' => 'An array of aggregated number of database writes.',
'default' => [],
'example' => [],
'array' => true
])
;
}
+3 -3
View File
@@ -143,7 +143,7 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(25, count($response['body']));
$this->assertEquals(29, count($response['body']));
$this->validateDates($response['body']['network']);
$this->validateDates($response['body']['requests']);
$this->validateDates($response['body']['users']);
@@ -324,7 +324,7 @@ class UsageTest extends Scope
]
);
$this->assertEquals(25, count($response['body']));
$this->assertEquals(29, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
@@ -545,7 +545,7 @@ class UsageTest extends Scope
]
);
$this->assertEquals(25, count($response['body']));
$this->assertEquals(29, count($response['body']));
$this->assertEquals(1, count($response['body']['requests']));
$this->assertEquals(1, count($response['body']['network']));
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
@@ -224,7 +224,7 @@ class DatabasesConsoleClientTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(7, count($response['body']));
$this->assertEquals(11, count($response['body']));
$this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['documentsTotal']);
$this->assertIsNumeric($response['body']['collectionsTotal']);