Feat new usage stats by ArnabChatterjee20k · Pull Request #13463 · appwrite/appwrite · GitHub
Skip to content

Feat new usage stats - #13463

Merged
ArnabChatterjee20k merged 20 commits into
mainfrom
feat-new-usage-stats
Sep 18, 2026
Merged

ArnabChatterjee20k merged 20 commits into
mainfrom
feat-new-usage-stats

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

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?

@greptile-apps

greptile-apps Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Comment on lines +274 to 278
'acceptLanguage' => $this->acceptLanguage,
'cookie' => $this->cookie,
'queryKeys' => $this->queryKeys,
];

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.

P1 Request metadata remains empty

When production requests emit usage metrics, request initialization never invokes the five new setters, so protocol, accept, acceptLanguage, cookie, and queryKeys are always recorded as empty strings and the new usage statistics are never collected.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Usage/Context.php
Line: 274-278

Comment:
**Request metadata remains empty**

When production requests emit usage metrics, request initialization never invokes the five new setters, so `protocol`, `accept`, `acceptLanguage`, `cookie`, and `queryKeys` are always recorded as empty strings and the new usage statistics are never collected.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@greptile this is already fixed

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.

Confirmed — this is fixed in the current revision. app/controllers/general.php now populates protocol, accept, acceptLanguage, and queryKeys before usage metrics are emitted, so these fields are no longer always empty. The cookie field is not part of the current implementation. Resolving this comment.

Comment thread src/Appwrite/Usage/Context.php
@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → feat-new-usage-stats (after).

Metric Before After Change
🚀 Requests/sec 233.41 230.35 ⚪ -1.3%
⏱️ Latency P50 74.67 ms 76.7 ms ⚪ +2.7%
⏱️ Latency P95 176.71 ms 173.85 ms ⚪ -1.6%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 76.7 173.85 14,478 230.35 -2.86
Account 139.59 260.47 762 12.62 -2.86
TablesDB 74.76 140.14 7,874 127.89 +3.36
Storage 68.51 155.14 3,810 63.59 -3.99
Functions 105.86 204.75 2,032 34.62 -13.31

Top API waits (after)

API request Max wait (ms)
functions.delete 456.12
account.prefs.update 402.55
account.name.update 398.07
tablesdb.rows.update 340.03
functions.create 334.97

Comment thread tests/unit/Usage/ContextTest.php Outdated
Comment thread src/Appwrite/Usage/Context.php
ArnabChatterjee20k and others added 4 commits September 3, 2026 15:09
StatsUsage rebuilt the tag set without the request-attribute dimensions,
so the metadata Context queued was discarded before collection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
# Conflicts:
#	composer.json
#	composer.lock
Use the new utopia-php/http TrustedHeaders constructor argument instead of
the removed Request::setTrustedIpHeaders(), and pass the single topic
Document to the cursor (getDocument() returns a Document, not an array),
resolving both level-4 PHPStan errors on the branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment on lines +213 to +238

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.

P1 S3 request metadata stays empty

When an S3 request records network usage, the separate S3 initialization hook omits setProtocol, setAccept, setAcceptLanguage, and setQueryKeys, causing all S3 traffic to be grouped under empty values for these newly queryable dimensions.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Usage/Context.php
Line: 213-238

Comment:
**S3 request metadata stays empty**

When an S3 request records network usage, the separate S3 initialization hook omits `setProtocol`, `setAccept`, `setAcceptLanguage`, and `setQueryKeys`, causing all S3 traffic to be grouped under empty values for these newly queryable dimensions.

**Knowledge Base Used:**
- [API platform and request surface](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/api-platform.md)
- [Background processing and scheduling](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/appwrite/-/docs/background-processing.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

The S3 gateway init hook meters network usage through its own context
setup and omitted the new protocol, accept, accept-language, and
query-key dimensions, so all S3 traffic grouped under empty values.
Mirror app/controllers/general.php so S3 requests carry the same fields.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ArnabChatterjee20k
ArnabChatterjee20k merged commit 6b2938a into main Sep 18, 2026
94 of 95 checks passed
@ArnabChatterjee20k
ArnabChatterjee20k deleted the feat-new-usage-stats branch September 18, 2026 08:51
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