Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function action(string $databaseId, string $range, UtopiaResponse $respon
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_COLLECTIONS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_DOCUMENTS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_STORAGE),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASES_OPERATIONS_READS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASES_OPERATIONS_WRITES)
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_READS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_WRITES)
];
Comment on lines +80 to 82
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Correct metric key fix — aligns with per-database metrics.

Switching to METRIC_DATABASE_ID_OPERATIONS_READS/WRITES matches the other ID-scoped metrics in this endpoint and should pull the right time series for the selected database.

Run this to confirm constants exist and there are no lingering references to the old keys:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Check for any remaining old metric keys (should be empty):"
rg -nP --glob '!**/vendor/**' 'METRIC_DATABASES_OPERATIONS_(READS|WRITES)' -C2 || true

echo -e "\nVerify new constants are defined and referenced:"
rg -nP --glob '!**/vendor/**' 'METRIC_DATABASE_ID_OPERATIONS_(READS|WRITES)' -C3

echo -e "\nSpot-check other database-ID metrics for consistency with placeholder usage:"
rg -n --glob '!**/vendor/**' '{databaseInternalId}' -C2 | rg -n 'METRIC_DATABASE_ID_' -C2

Length of output: 406


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT

# Produce a newline-separated file list: prefer git-tracked files if inside a repo, otherwise fallback to find
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
  git ls-files > "$tmp" || true
else
  find . -type f -not -path './vendor/*' -not -path './.git/*' -print > "$tmp" || true
fi

if [ ! -s "$tmp" ]; then
  echo "No files found to search."
  exit 0
fi

echo "Searching for old metric keys (METRIC_DATABASES_OPERATIONS_(READS|WRITES))..."
xargs -a "$tmp" grep -nE "METRIC_DATABASES_OPERATIONS_(READS|WRITES)" || true

echo
echo "Searching for new metric keys (METRIC_DATABASE_ID_OPERATIONS_(READS|WRITES))..."
xargs -a "$tmp" grep -nE "METRIC_DATABASE_ID_OPERATIONS_(READS|WRITES)" || true

echo
echo "Searching for placeholder '{databaseInternalId}' occurrences..."
xargs -a "$tmp" grep -nF "{databaseInternalId}" || true

echo
echo "Searching for METRIC_DATABASE_ID_ constant definitions (define(...) or const ...)..."
xargs -a "$tmp" grep -nE "define\\s*\\(\\s*['\"]METRIC_DATABASE_ID_|const\\s+METRIC_DATABASE_ID_" || true

Length of output: 264289


Missing METRIC_DATABASE_ID_OPERATIONS_ constants — define them or revert the change.*

Get.php (src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php — lines 80–82) now uses METRIC_DATABASE_ID_OPERATIONS_READS/WRITES but those constants are not defined; app/init/constants.php defines METRIC_DATABASES_OPERATIONS_READS/WRITES (lines 189,191) and other code still references the old keys (app/controllers/api/project.php — lines 70–71, 83–84, 366–371).

  • Add the new constants to app/init/constants.php, for example:
    const METRIC_DATABASE_ID_OPERATIONS_READS = 'databases.{databaseInternalId}.operations.reads';
    const METRIC_DATABASE_ID_OPERATIONS_WRITES = 'databases.{databaseInternalId}.operations.writes';
  • Or revert src/.../Get.php (lines 80–82) to use the existing METRIC_DATABASES_OPERATIONS_* keys if per-database series aren’t supported yet.
  • Verify no mixed references remain (app/controllers/api/project.php and docs like CONTRIBUTING.md around the {databaseInternalId} placeholders).
🤖 Prompt for AI Agents
In src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php around
lines 80-82, the code now references METRIC_DATABASE_ID_OPERATIONS_READS/WRITES
which do not exist; either add these two constants to app/init/constants.php or
revert Get.php to use the existing METRIC_DATABASES_OPERATIONS_READS/WRITES
keys. To fix: if you intend per-database metric keys, add constants in
app/init/constants.php with the patterns
'databases.{databaseInternalId}.operations.reads' and
'databases.{databaseInternalId}.operations.writes' and update any other mixed
references; otherwise change the three str_replace calls in Get.php back to
METRIC_DATABASES_OPERATIONS_READS/WRITES so they match existing constants and
ensure no other files (e.g., app/controllers/api/project.php or docs) reference
the new keys.


Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {
Expand Down