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: add profiling to Superset pages #16136

Merged
merged 2 commits into from
Aug 9, 2021

Conversation

betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented Aug 8, 2021

SUMMARY

Add Python instrumentation to pages, showing method calls used to build the page, and how long each one took.

Requires a configuration flag PROFILING=True, and appending _instrument=1 to the URL.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

http://localhost:9000/superset/welcome/?_instrument=1

Screenshot 2021-08-08 at 11-58-21 0 417s - call - pyinstrument

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

superset/app.py Outdated
@@ -36,6 +37,10 @@ def create_app() -> Flask:
app_initializer = app.config.get("APP_INITIALIZER", SupersetAppInitializer)(app)
app_initializer.init_app()

profiling = app.config.get("PROFILING", False)
if profiling:
app.wsgi_app = SupersetProfiler(app.wsgi_app) # type: ignore
Copy link
Member Author

Choose a reason for hiding this comment

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

@codecov
Copy link

codecov bot commented Aug 8, 2021

Codecov Report

Merging #16136 (aaece1d) into master (3bbcc30) will decrease coverage by 0.25%.
The diff coverage is 62.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16136      +/-   ##
==========================================
- Coverage   76.83%   76.58%   -0.26%     
==========================================
  Files         995      996       +1     
  Lines       52884    52913      +29     
  Branches     6721     6721              
==========================================
- Hits        40636    40526     -110     
- Misses      12023    12162     +139     
  Partials      225      225              
Flag Coverage Δ
hive ?
mysql ?
postgres 81.58% <62.06%> (-0.03%) ⬇️
presto ?
python 81.62% <62.06%> (-0.50%) ⬇️
sqlite 81.22% <62.06%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/utils/profiler.py 47.05% <47.05%> (ø)
superset/initialization/__init__.py 87.72% <75.00%> (-0.19%) ⬇️
superset/extensions.py 92.68% <85.71%> (-0.66%) ⬇️
superset/config.py 91.27% <100.00%> (+0.02%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.80% <0.00%> (-16.87%) ⬇️
superset/db_engine_specs/presto.py 83.47% <0.00%> (-6.49%) ⬇️
superset/db_engine_specs/mysql.py 94.04% <0.00%> (-3.58%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/connectors/sqla/models.py 88.08% <0.00%> (-1.67%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3bbcc30...aaece1d. Read the comment docs.

superset/app.py Outdated Show resolved Hide resolved
from werkzeug.wrappers import Request, Response


class SupersetProfiler:
Copy link
Member

@john-bodley john-bodley Aug 9, 2021

Choose a reason for hiding this comment

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

@betodealmeida would this be better defined an extension?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still need the WSGI middleware, but I'll add an extension to register and set it up.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

This is great, LGTM after addressing @john-bodley comment(s)

@betodealmeida betodealmeida merged commit 2db1615 into apache:master Aug 9, 2021
villebro pushed a commit to preset-io/superset that referenced this pull request Oct 12, 2021
* feat: add profiling to Superset pages

* Address comments
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
* feat: add profiling to Superset pages

* Address comments
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
* feat: add profiling to Superset pages

* Address comments
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants