Skip to content

Preserve dashboard metrics when accounts are removed #525

Closed

Description

@mgwals

Problem

Removing an account currently changes historical dashboard metrics because account deletion removes the rows that account contributed to the dashboard.

From the current code path, account deletion explicitly deletes UsageHistory and RequestLog rows for the account before deleting the Account row. RequestLog.account_id also has a cascading foreign key, so hard-deleting an account can remove historical request data that should remain part of aggregate observability.

That makes dashboards and historical totals unstable: removing an account from the pool can rewrite past token, cost, request, error, or usage-history metrics.

Expected behavior

Removing an account from active use should not change already-recorded historical dashboard metrics.

The account should no longer be routable or usable after removal, but historical aggregate metrics should remain stable for windows that already include that account's activity.

Suggested direction

Prefer an account archival/removal model over destructive metric deletion:

  • Remove the account from active routing and assignment surfaces.
  • Preserve historical request and usage rows, or preserve an equivalent immutable metric snapshot.
  • Avoid retaining usable credentials for removed accounts.
  • Keep deleted/archived account identity available only as much as needed for historical dashboard attribution.

A smaller partial approach could detach request logs from the deleted account instead of deleting them, but that likely loses attribution and may not cover UsageHistory, so it should be treated as a fallback rather than the ideal behavior.

Acceptance criteria

  • Deleting/removing an account does not reduce historical aggregate dashboard totals for already-recorded request logs.
  • Request/cost/token/error metrics remain stable after account removal.
  • Usage history behavior is explicitly defined and covered by tests.
  • Removed accounts are not selected for new proxy traffic.
  • Removed accounts do not retain usable credentials unless there is a deliberate archival design that protects them.
  • Regression tests cover account removal with existing RequestLog and UsageHistory rows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions