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: improve event logging for queries + refactor #27943

Merged
merged 11 commits into from
Apr 22, 2024
Merged

Conversation

mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented Apr 8, 2024

SUMMARY

The main driver for this PR was to enrich event logging around database engine and database drivers for events that interact directly with analytics databases. While touching this up, I did some refactor along the way.

  • Adding a new analytics event/action execute_sql that targets just that, that isn't called when hitting the cache for instance. Using the context manager insures capturing the duration of the call as well.
  • refactored logic duplication around config items SQL_QUERY_MUTATOR and MUTATE_AFTER_SPLIT, where code had been copy/pasted and reimplemented in various places. Here I move it as a method of the Database model.
  • side mission: I realized that request.form is empty when posting JSON payload, and request.json should be used instead. This should automatically capture more automated logging that parses context out of the request object proactively
  • factored out post_process_df as it seemed logical to isolate this out of get_df
  • fix cypress glitch + improved cypress docs

superset/utils/log.py Outdated Show resolved Hide resolved
The driver for this PR was to enrich event logging around database engine and database drivers for events that interact directly with analytics databases.

Digging a bit into the logging code:
- I realized that `request.form` is empty when pushing JSON payload, and
  `request.json` should be used. This should automatically capture more
  automated logging that parses context out of the request object
  proactively
- Adding an event `execute_sql` that targets just that, that **isn't**
  called when hitting the cache for instance. Using the context manager
  insures capturing the duration of the call as well.
- a bit of refactor here and there
@github-actions github-actions bot added the doc Namespace | Anything related to documentation label Apr 16, 2024
@mistercrunch mistercrunch marked this pull request as ready for review April 16, 2024 16:40
@john-bodley john-bodley added risk:breaking-change Issues or PRs that will introduce breaking changes hold! On hold labels Apr 16, 2024
@mistercrunch mistercrunch removed risk:breaking-change Issues or PRs that will introduce breaking changes hold! On hold labels Apr 16, 2024
Copy link
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Looks great! Left a few suggestions.

superset/models/core.py Outdated Show resolved Hide resolved
superset/models/core.py Show resolved Hide resolved
superset/utils/log.py Outdated Show resolved Hide resolved
Co-authored-by: Beto Dealmeida <[email protected]>
@mistercrunch mistercrunch merged commit cfc440c into master Apr 22, 2024
29 checks passed
@mistercrunch mistercrunch deleted the log_queries branch April 22, 2024 23:30
qleroy pushed a commit to qleroy/superset that referenced this pull request Apr 28, 2024
jzhao62 pushed a commit to jzhao62/superset that referenced this pull request May 16, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 4.1.0 labels Nov 27, 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 doc Namespace | Anything related to documentation preset-io size/L 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants