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(alerts & reports): Easier to read execution logs #13752

Merged
merged 20 commits into from
Mar 30, 2021

Conversation

jfrag1
Copy link
Member

@jfrag1 jfrag1 commented Mar 23, 2021

SUMMARY

Currently, reading execution logs for alerts and reports can be confusing. Several log entries can be created by a single execution run, but nothing indicates that they are part of the same execution, except that they have the same timestamp.

This PR gives each execution a UUID which is truncated to 6 characters on the execution log view. This way, it will be much easier to tell which log entries belong to which execution.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
Screen Shot 2021-03-23 at 1 33 22 PM

After:
Screen Shot 2021-03-23 at 1 34 44 PM

TEST PLAN

I've only tested manually.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@jfrag1 jfrag1 changed the title Easier to read execution logs feat(alerts & reports): Easier to read execution logs Mar 23, 2021
@codecov
Copy link

codecov bot commented Mar 23, 2021

Codecov Report

Merging #13752 (fac8f58) into master (467848d) will increase coverage by 1.99%.
The diff coverage is 83.33%.

❗ Current head fac8f58 differs from pull request most recent head 039f056. Consider uploading reports for the commit 039f056 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13752      +/-   ##
==========================================
+ Coverage   75.56%   77.56%   +1.99%     
==========================================
  Files         935      935              
  Lines       47275    47286      +11     
  Branches     5883     5883              
==========================================
+ Hits        35725    36679     +954     
+ Misses      11375    10463     -912     
+ Partials      175      144      -31     
Flag Coverage Δ
cypress 56.07% <ø> (+8.37%) ⬆️
hive 80.29% <77.77%> (+<0.01%) ⬆️
javascript 63.75% <100.00%> (+<0.01%) ⬆️
mysql 80.60% <77.77%> (+<0.01%) ⬆️
postgres 80.63% <77.77%> (+<0.01%) ⬆️
presto 80.30% <77.77%> (+<0.01%) ⬆️
python 81.14% <77.77%> (+<0.01%) ⬆️
sqlite 80.19% <77.77%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset-frontend/src/views/CRUD/alert/types.ts 100.00% <ø> (ø)
superset/reports/logs/api.py 95.45% <ø> (ø)
superset/tasks/scheduler.py 0.00% <0.00%> (ø)
...set-frontend/src/views/CRUD/alert/ExecutionLog.tsx 100.00% <100.00%> (ø)
superset/models/reports.py 100.00% <100.00%> (ø)
superset/reports/commands/execute.py 93.58% <100.00%> (+0.14%) ⬆️
...erset-frontend/src/SqlLab/components/ResultSet.tsx 68.64% <0.00%> (-0.30%) ⬇️
...set-frontend/src/dashboard/util/getDropPosition.js 90.90% <0.00%> (ø)
superset-frontend/src/components/ListView/utils.ts 85.95% <0.00%> (+0.82%) ⬆️
.../src/explore/components/ControlPanelsContainer.tsx 97.27% <0.00%> (+0.90%) ⬆️
... and 113 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 33f7845...039f056. Read the comment docs.

@lilykuang lilykuang added the risk:db-migration PRs that require a DB migration label Mar 23, 2021
@ktmud
Copy link
Member

ktmud commented Mar 23, 2021

Why do we have duplicate execution IDs in the screenshot? Is it because of testing?

def upgrade():
op.add_column(
'report_execution_log',
sa.Column('execution_id', sa.VARCHAR(length=50), nullable=True)
Copy link
Member

@ktmud ktmud Mar 23, 2021

Choose a reason for hiding this comment

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

Can we simply call it uuid and use sa.Column('uuid', UUIDType(binary=True)) just to be consistent with other entities in Superset?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! I wasn't aware there was a column type specifically for UUID's.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we'll be having multiple log entries with the same UUID, would it be confusing to name the column uuid?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can call it UUID internally and just change the display name.

@nytai
Copy link
Member

nytai commented Mar 23, 2021

@ktmud The screenshot is of the execution log, so multiple entries for each alert/report execution is expected. The id is tied to a single execution/run, for which there will be multiple log entries. The id makes it easier to visually group the logs for each run.

@jfrag1 Do we have designs for this? Wondering if adding the "Execution ID" after "State" makes more sense

@jfrag1
Copy link
Member Author

jfrag1 commented Mar 23, 2021

@nytai No, I'm not aware of any designs. It would be good to get some designer eyes on this.

@ktmud
Copy link
Member

ktmud commented Mar 23, 2021

What does the log page as a whole look like?

I think a simple way to improve the visual grouping is to maybe set rowspan on the "Execution ID" column (and any other common columns). If all log entries are guaranteed to have the same info for almost all columns, then maybe you can just show one row per execution and have multiple box/links for different log entry in one "Logs" cell.

@jfrag1
Copy link
Member Author

jfrag1 commented Mar 23, 2021

Here is what the entire row looks like:

Screen Shot 2021-03-23 at 4 06 22 PM

I believe the only columns guaranteed to be the same are execution id and value. The timestamps are the same currently, but there are plans to change them to show milliseconds so that order of execution be be more clearly seen, so those will be different.

@nytai
Copy link
Member

nytai commented Mar 23, 2021

I think it's also possible for runs to overlap. Eg, if one execution is taking a while (slow query, capturing screenshot) and the next execution begins.

@mihir174
Copy link
Contributor

Hey, just catching up with context here! Is this PR referring to the log that appears after clicking the Log button in the actions column of an alert or report?

I worked on designs for alerts & reports a while ago. There weren't any designs produced for the log at the time since the team wasn't sure columns would need to be included. If this is what i think it is, some thoughts -

  • the ID to group / differentiate between execution events makes sense
  • the State column should live on the far left

@jfrag1
Copy link
Member Author

jfrag1 commented Mar 23, 2021

@mihir174 Yes, this is the log shown after clicking the Log button. I'll switch the State and Execution ID columns. Thanks for the input!

@github-actions
Copy link
Contributor

⚠️ @jfrag1 Your base branch master has just also updated superset/migrations.

Please consider rebasing your branch to avoid db migration conflicts.

@jfrag1 jfrag1 force-pushed the easier-to-read-execution-logs branch 2 times, most recently from fb7283e to 2bdc232 Compare March 26, 2021 03:09
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.

Looking good, left a couple of comments. We should also update tests and make sure we get these exact columns there, here: https://github.com/apache/superset/blob/master/tests/reports/api_tests.py#L1074

@@ -171,6 +172,7 @@ class ReportExecutionLog(Model): # pylint: disable=too-few-public-methods

__tablename__ = "report_execution_log"
id = Column(Integer, primary_key=True)
uuid = Column(UUIDType(binary=True))
Copy link
Member

@dpgaspar dpgaspar Mar 26, 2021

Choose a reason for hiding this comment

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

We probably should think about moving out of sqlalchemy_utils...

Copy link
Member

Choose a reason for hiding this comment

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

We're already pretty tied to it - this doesn't tie us any deeper. I think it's OK for now.

@@ -403,6 +407,7 @@ def __init__(
self._session = session
self._report_schedule = report_schedule
self._scheduled_dttm = scheduled_dttm
self._execution_id = uuid4()
Copy link
Member

Choose a reason for hiding this comment

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

Have you checked if we can use celery's UUID, and pass it into the AsyncExecuteReportScheduleCommand constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

The closest thing I found to this is this Github issue, but it only described how it could be done when triggering tasks with delay or apply_async, and I wasn't sure how to do it for a task triggered by a beat schedule.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually scratch that, I tweaked my Google search and found this, let me see if I can get it to work.

Copy link
Member

Choose a reason for hiding this comment

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

The delay is invoked by the caller.

use <job_name>.request.id to get the id, then use it here:
https://github.com/apache/superset/blob/master/superset/tasks/scheduler.py#L67

on this case should be execute.request.id

Copy link
Member

Choose a reason for hiding this comment

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

check if you need to use the bind=True and then self.request.id to bind the function to the task class.
https://docs.celeryproject.org/en/latest/userguide/tasks.html?highlight=requestcontext#basics

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, execute.request.id worked!

@jfrag1
Copy link
Member Author

jfrag1 commented Mar 26, 2021

Here's what the list view looks like now with the state column at the far left:

Screen Shot 2021-03-26 at 9 47 45 AM

@pull-request-size pull-request-size bot added size/L and removed size/M labels Mar 28, 2021
Copy link
Member

@willbarrett willbarrett left a comment

Choose a reason for hiding this comment

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

LGTM

@willbarrett
Copy link
Member

@jfrag1 I think this needs a rebase.

@jfrag1
Copy link
Member Author

jfrag1 commented Mar 29, 2021

On it!

@jfrag1 jfrag1 force-pushed the easier-to-read-execution-logs branch from aa48d1a to 039f056 Compare March 29, 2021 20:39
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.

LGTM

@willbarrett willbarrett merged commit 304e3b3 into apache:master Mar 30, 2021
@jfrag1 jfrag1 deleted the easier-to-read-execution-logs branch March 30, 2021 15:58
amitmiran137 pushed a commit that referenced this pull request Mar 31, 2021
* master: (56 commits)
  test: Adds tests and storybook to CertifiedIcon component (#13457)
  chore: Moves CheckboxIcons to Checkbox folder (#13459)
  chore: Removes Popover duplication (#13462)
  build(deps): bump elliptic from 6.5.3 to 6.5.4 in /docs (#13527)
  fix: allow spaces in DB names (#13800)
  chore: Update PR template for SIP-59 DB migrations process (#13855)
  Add CODEOWNERS (#13759)
  feat(alerts & reports): Easier to read execution logs (#13752)
  fix: Disallows negative options remaining (#13749)
  Fix broken link (#13861)
  fix(native-filters): add global async query support to native filters (#13837)
  Displays row limit warning with Alert component (#13854)
  fix(errors): Downgrade error on stop query to a warning (#13826)
  fix(alerts and reports): Unify timestamp format on execution log view (#13718)
  fix(sqllab): warning message when rows limited (#13841)
  chore: add success log whenever a connection is working (#13811)
  fix(native-filters): improve loading styles for filter component (#13794)
  chore: update change log with cherry-picks for release 1.1 (#13824)
  feat: added support to configure the default explorer viz (#13610)
  fix(#13734): Properly escape special characters in CSV output  (#13735)
  ...
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
* Prep for migration

* Migration for execution id column

* Generate execution ids for alerts and reports

* Change execution id range

* Add execution id to API endpoint

* Add execution id to execution log view

* Change execution id range

* Change execution id to a uuid

* Fix execution id type

* Switch state and exec. id columns

* Change db column to UUIDType

* Python lint

* Fix failing frontend tests

* execution_id -> uuid

* Fix migration head

* lint

* Use celery task id as the execution id

* lint

* lint for real

* Fix tests


def downgrade():
op.drop_column("report_execution_log", "execution_id")
Copy link
Member

Choose a reason for hiding this comment

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

The column execution_id doesn't exist.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 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 risk:db-migration PRs that require a DB migration size/L 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants