8000 Feat: stats sites and functions runtimes and frameworks by lohanidamodar · Pull Request #10786 · appwrite/appwrite · GitHub
[go: up one dir, main page]

Skip to content

Feat: stats sites and functions runtimes and frameworks#10786

Merged
lohanidamodar merged 2 commits into1.8.xfrom
feat-function-sites-stats
Nov 10, 2025
Merged

Feat: stats sites and functions runtimes and frameworks#10786
lohanidamodar merged 2 commits into1.8.xfrom
feat-function-sites-stats

Conversation

@lohanidamodar
Copy link
Member
@lohanidamodar lohanidamodar commented Nov 9, 2025

What does this PR do?

  • Sites frameworks count
  • Functions runtimes count

Preview:
image

image

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

- Sites frameworks count
- Functions runtimes count
@coderabbitai
Copy link
Contributor
coderabbitai bot commented Nov 9, 2025
📝 Walkthrough

Walkthrough

Added two metric constants in app/init/constants.php: METRIC_FUNCTIONS_RUNTIME = 'functions.runtimes.{runtime}' and METRIC_SITES_FRAMEWORK = 'sites.frameworks.{framework}'. Updated src/Appwrite/Platform/Workers/StatsResources.php to aggregate counts per function runtime and per site framework while iterating documents, store those counts in temporary maps, and persist the aggregated metrics using the existing stats creation mechanism.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check that runtime and framework values are extracted from the correct document fields and handle missing/null values consistently.
  • Verify the metric constant identifiers are referenced exactly as declared.
  • Inspect the accumulation logic for duplicate counting or off-by-one issues during iteration.
  • Confirm createStatsDocuments/write-back loops correctly format keys and counts for the new metrics.
  • Review potential performance/memory impact of the temporary maps if many distinct runtimes/frameworks appear.
  • Files to focus on: app/init/constants.php and src/Appwrite/Platform/Workers/StatsResources.php.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Feat: stats sites and functions runtimes and frameworks' accurately describes the main changes: adding stats counting for sites frameworks and functions runtimes, as confirmed by the changeset.
Description check ✅ Passed The description is related to the changeset, clearly stating 'Sites frameworks count' and 'Functions runtimes count' which matches the modifications in the pull request files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-function-sites-stats

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
github-actions bot commented Nov 9, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.44-r2 CVE-2025-5244 HIGH
binutils 2.44-r2 CVE-2025-5245 HIGH
libxml2 2.13.8-r0 CVE-2025-49794 CRITICAL
libxml2 2.13.8-r0 CVE-2025-49796 CRITICAL
libxml2 2.13.8-r0 CVE-2025-49795 HIGH
libxml2 2.13.8-r0 CVE-2025-6021 HIGH
pcre2 10.43-r1 CVE-2025-58050 CRITICAL
github.com/containerd/containerd/v2 v2.0.2 CVE-2024-25621 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH
stdlib 1.22.10 CVE-2025-47912 HIGH
stdlib 1.22.10 CVE-2025-58183 HIGH
stdlib 1.22.10 CVE-2025-58186 HIGH
stdlib 1.22.10 CVE-2025-58187 HIGH
stdlib 1.22.10 CVE-2025-58188 HIGH
stdlib 1.22.10 CVE-2025-61724 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@github-actions
Copy link
github-actions bot commented Nov 9, 2025

✨ Benchmark results

  • Requests per second: 1,187
  • Requests with 200 status code: 213,721
  • P99 latency: 0.163839668

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,187 1,187
200 213,721 213,674
P99 0.163839668 0.177471226

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Appwrite/Platform/Workers/StatsResources.php (1)

404-443: Consider extracting the aggregation pattern.

The framework counting logic mirrors the runtime counting pattern (lines 338-383). While the current implementation is correct and clear, you could reduce duplication by extracting a helper method:

private function countByAttribute(
    Database $dbForProject,
    string $collection,
    string $attribute,
    string $metricTemplate,
    string $region,
    array $queries = []
): void {
    $counts = [];
    
    $this->foreachDocument($dbForProject, $collection, $queries, function (Document $doc) use ($attribute, &$counts) {
        $value = $doc->getAttribute($attribute);
        if (!empty($value)) {
            $counts[$value] = ($counts[$value] ?? 0) + 1;
        }
    });
    
    foreach ($counts as $value => $count) {
        $this->createStatsDocuments($region, str_replace("{{$attribute}}", $value, $metricTemplate), $count);
    }
}

This is optional since the duplication is limited and the current approach is straightforward.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b7a749 and 4fd4af3.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Workers/StatsResources.php (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Appwrite/Platform/Workers/StatsResources.php (2)
src/Appwrite/Platform/Action.php (1)
  • foreachDocument (49-108)
src/Appwrite/Utopia/Response/Model/Document.php (1)
  • Document (8-115)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Benchmark
  • GitHub Check: Setup & Build Appwrite Image
🔇 Additional comments (1)
src/Appwrite/Platform/Workers/StatsResources.php (1)

338-383: LGTM! Runtime counting implementation is correct.

The runtime aggregation logic properly accumulates counts per runtime value and persists them using the existing stats infrastructure. The !empty() check appropriately handles functions without a runtime attribute.

@lohanidamodar lohanidamodar merged commit add1142 into 1.8.x Nov 10, 2025
43 checks passed
@lohanidamodar lohanidamodar deleted the feat-function-sites-stats branch November 10, 2025 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0