-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Add endpoint for DB stats #50758
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
base: main
Are you sure you want to change the base?
Add endpoint for DB stats #50758
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice thanks
Can we add tests for endpoint.
Can you provide more context to why this public endpoint is needed ?
Sorry for the early review, I just noticed it went to draft.
from airflow.utils.db import reflect_tables | ||
from airflow.utils.db_cleanup import _effective_table_names, calculate_table_size | ||
|
||
db_router = AirflowRouter(tags=["Maintenance"], prefix="/maintenance/db") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the maintenance
prefix/tag. Maybe db
is good enough ?
def calculate_table_size( | ||
*, | ||
table_name: str, | ||
session: Session, | ||
) -> float | None: | ||
"""Calculate table size in megabytes.""" | ||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the implementation is not done yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Wanted to keep few issues as good first issues for MLH internship folks to pick them up
I am adding an endpoint to retrieve DB stats. For now, I am including only the table's name, the oldest record present in the table, and the number of records in the table. This can be extended in the future.
TODO:
Add additional field to TableStats for size of the table in MB - Very useful to determine if a clean up is necessarywill be doing this as part of a separate PR