Skip to content

Add admin analytics for environments, components, and Agent usage - #253

Open
vmelikyan wants to merge 4 commits into
mainfrom
admin-analytics-api
Open

vmelikyan wants to merge 4 commits into
mainfrom
admin-analytics-api

Conversation

@vmelikyan

@vmelikyan vmelikyan commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Administrators can review environment activity, repository and PR use, current health, and recorded Agent usage from existing Lifecycle records.

Lifetime results separate recorded API retirements from PR estimates. API lifetime uses creation and deletion dates. PR estimates use creation and last update dates for records marked torn down. Later edits and reuse gaps can increase PR estimates. Missing measurements remain unavailable.

Unique components count each configured component once within its repository. Ready components count each component in each current environment. PostgreSQL in two repositories across 20 ready PR environments gives two unique components and 20 ready components. Exclusions and incomplete identities remain visible. Enabled optional components can be absent from the totals. This count defect remains open.

Results support time windows, filters, comparisons, and paged records. Agent usage follows submitted runs. Reported and estimated costs remain separate. Access requires administrator permission.

Migration 036 adds an index for active deployment lookups. Lifetime and component metrics need no additional migration.

PR coverage and component queries avoid repeated reads of retained records. Current inventory reads selected component rows once and preserves their latest recorded deployment state. Counts and filters are unchanged. Each Analytics SQL statement keeps a limit of 10 seconds.

In a local fixture with 5,000 current environments, inventory changed from a time-limit failure to 422 ms. A larger fixture used 20,000 current environments and 2.1 million rows in each retained component and deployment table. It completed in 7.9 seconds. These synthetic measurements depend on the device, data, and cache. They do not guarantee production latency. The reported production request has not been inspected, so its cause remains unconfirmed.

Confirmed PostgreSQL statement timeouts return HTTP 503 with analytics_timeout and a retry action. The response excludes database details. Other failures keep their existing handling. This timeout fix needs no new index or migration.

Validation: 9,594 API tests and 55 gateway tests passed, including CI coverage checks. Eleven existing API tests remain skipped. Lint, runtime TypeScript checks, and an isolated production build passed. PostgreSQL fixtures confirmed lifetime calculations, repository identity, component counts, exclusions, pagination, and count parity across 13 filter scopes. Additional PostgreSQL checks confirmed latest deployment selection, large-fixture counts, the timeout response, and connection recovery.

Commit and PR text review: passed against the final change and verification results.

UI text review: passed for API text shown in Analytics. Desktop Chrome confirmed measurement limits, unavailable data, known timeout responses, and manual recovery.

Deploy this API before the UI analytics change.

@vmelikyan
vmelikyan requested a review from a team as a code owner October 3, 2026 08:23
Add recorded API lifetimes and estimated lifetimes for torn-down PR environments.
Show unique components by repository and ready components across current environments.
Keep missing measurements unavailable.
Exclude incomplete identities from unique component counts.
@vmelikyan vmelikyan changed the title Add admin analytics for environments and Agent usage Add admin analytics for environments, components, and Agent usage Oct 3, 2026
The inventory query can reach its time limit as the number of current environments increases.
Read the selected component rows once and keep their latest deployment state for the result.
Counts and filters stay the same.

Return HTTP503 with analytics_timeout when PostgreSQL confirms a statement time limit.
Keep other failures unchanged and exclude database details from the response.
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