Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Statistics and information about instance #80

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

Brayden
Copy link
Member

@Brayden Brayden commented Jan 29, 2025

Purpose

The intent behind this pull request is to expose information about the deployed instance and expose it via a new route /_internal/stats when the ADMIN_AUTHORIZATION_TOKEN is passed in as the Authorization header. Primary driver for this is more of an internal business use case to populate a dashboard with metadata information for users to have quick insights to what is currently happening (reference image below).

image

Tasks

  • Show database size (in bytes)
  • Show recent queries count (dependent on QueryLogPlugin)
  • Show active persistent WebSocket connections in DO
  • Show names of installed plugins

Verify

curl --location --request GET 'https://starbasedb.{YOUR-IDENTIFIER}.dev/_internal/stats' \
--header 'Authorization: Bearer ABC123' \

Before

N/A

After

{
    "databaseSize": 65536,
    "activeConnections": 0,
    "recentQueries": 4,
    "plugins": [
        "starbasedb:websocket",
        "starbasedb:studio",
        "starbasedb:sql-macros",
        "starbasedb:query-log",
        "starbasedb:change-data-capture",
        "starbasedb:stats"
    ]
}

@Brayden Brayden self-assigned this Jan 29, 2025
@Brayden Brayden added the enhancement New feature or request label Jan 29, 2025
Copy link

github-actions bot commented Jan 29, 2025

Coverage Report

Status Category Percentage Covered / Total
🔴 Lines 2.07% (🎯 75%) 21 / 1010
🔴 Statements 1.98% (🎯 75%) 21 / 1057
🔴 Functions 2.99% (🎯 75%) 5 / 167
🔴 Branches 0% (🎯 75%) 0 / 594
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/do.ts 0% 0% 0% 0% 18-244
src/index.ts 0% 0% 0% 0% 16-286
src/plugin.ts 0% 0% 0% 0% 6-114
Generated in workflow #50 for commit 87e4db3 by the Vitest Coverage Report Action

@Brayden Brayden merged commit 75795bc into main Jan 29, 2025
1 check passed
@Brayden Brayden deleted the bwilmoth/internal-stats branch January 29, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant