Skip to content

feat(realtime): report worker uptime gauge - #15114

Merged
ArnabChatterjee20k merged 2 commits into
fix/realtime-permission-ingest-fail-closedfrom
feat/realtime-uptime-gauge-on-ingest
Oct 30, 2026
Merged

ArnabChatterjee20k merged 2 commits into
fix/realtime-permission-ingest-fail-closedfrom
feat/realtime-uptime-gauge-on-ingest

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Member

Issue / Description

Closes #15108. Stacked on #15086.

Every realtime server metric is a counter or histogram, recorded only when something happens. A worker that is up but not processing anything exports nothing, which looks exactly like a quiet region. A freshly rolled worker is invisible until traffic arrives.

Solution

Adds realtime.server.uptime: an observable gauge of the seconds since the realtime worker started, tagged with the worker id. It is observed on every telemetry collect, whatever the traffic, and resets to zero on restart. It mirrors mqtt.server.uptime in app/mqtt.php.

With it, alerts can tell three cases apart:

  • worker gone: no uptime series
  • worker restarted: uptime drops to zero
  • worker alive but delivering nothing: uptime rising while realtime.server.message.sent stays flat

Tests

  • php -l and Pint on app/realtime.php.
  • No automated test: this is the app/ harness, which isn't unit-tested, and the MQTT gauge it mirrors has none either.

🤖 Generated with Claude Code

@luxor-code-review

luxor-code-review Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This change instruments the realtime worker with an observable uptime gauge, reported on every metrics collect so even an idle or stalled worker shows up in telemetry. It is guarded against the NoTelemetry adapter and intentionally registers no collect timer, relying on getTelemetry()'s existing one.

Files Change
app/realtime.php Captures the worker start time, creates an observable realtime.server.uptime gauge when telemetry is available, and observes elapsed seconds using the existing worker telemetry attributes on each collect.

Reviewed commit: ee6269a

@ghost

ghost commented Oct 30, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Adds an observable realtime.server.uptime gauge with a per-worker attribute, intended to expose worker liveness independently of traffic. The gauge callback computes elapsed seconds from the worker start time.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 1
File Change
app/realtime.php Registers a per-worker observable uptime gauge.
🔇 Filtered out · 1

Findings Hansi considered but did not post.

Finding Why
Realtime uptime is never exported Verifier: The NoTelemetry fallback and function_exists('getTelemetry') override hook already exist in the base version (app/realtime.php:218–228); this change does not disable telemetry. The repository likewise defaults its DI telemetry resource to NoTelemetry (app/init/resources.php:191). A telemetry-enabled realtime deployment must supply an override, whose collection lifecycle is not present here. Consequently, the absence of a local collect timer does not establish that the enabled deployment fails to export. The new gauge is correctly retained by OpenTelemetry::createMeter(), and observe() registers its callback with the underlying meter (packages/telemetry/src/Adapter/OpenTelemetry.php:128–133, 269–307). There is no demonstrated reachable telemetry-enabled path lacking collection; the finding treats the existing opt-out default as a feature failure and assumes the behavior of an unavailable override.

Reviewed ee6269a · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ArnabChatterjee20k
ArnabChatterjee20k merged commit c581964 into fix/realtime-permission-ingest-fail-closed Oct 30, 2026
18 checks passed

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing fix/realtime-permission-ingest-fail-closed (before) → feat/realtime-uptime-gauge-on-ingest (after).

Metric Before After Change
🚀 Requests/sec 205.03 207.89 ⚪ +1.4%
⏱️ Latency P50 83.29 ms 82.74 ms ⚪ -0.7%
⏱️ Latency P95 198.11 ms 198.07 ms ⚪ 0%
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 82.74 198.07 12,825 207.89 -0.04
Account 154 272.09 675 11.22 -60.43
TablesDB 78.13 143.07 6,975 114.92 -11.71
Storage 80.44 201.89 3,375 57.53 +8.67
Functions 119.4 223.43 1,800 31.45 -5.81

Top API waits (after)

API request Max wait (ms)
tokens.files.create 437.4
functions.delete 427.43
storage.buckets.create 405.59
account.name.update 388.64
account.prefs.update 370.92

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.

1 participant