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

cluster-ui: update statements page #178

Merged
merged 3 commits into from
Feb 2, 2021
Merged

cluster-ui: update statements page #178

merged 3 commits into from
Feb 2, 2021

Conversation

asubiotto
Copy link
Contributor

@asubiotto asubiotto commented Jan 22, 2021

This commit adds columns for execution stats that we want to display for 21.1.
Namely, this adds rows/bytes read, max memory, and network bytes sent. The
rows affected column has been removed.
The commit also reorders all column-related code to follow the graphical order.

Here is what that looks like with some example queries run against tpch:
image

Closes cockroachdb/cockroach#59294

Please let me know which tests to update and how. I have run into some issues with "accessing property mean of undefined" which is most likely due to unset proto fields. Is that something I need to handle in the protojs package in cockroach? If not, I'd appreciate if someone could point me to how to write tests for this and other cases.

I'm explicitly not adding code to handle cases when the stats haven't been collected. I leave this for the future if we decide to keep the sampling cluster setting. I focused on just getting the stats out there using preexisting components.

Checklist

  • Decide whether to remove the TXN Type column. The design doesn't have it, but want to double check cc @awoods187 @Annebirzin
  • I have written or updated test for the changes I made
  • I have updated the README of the package I'm working in to reflect my changes
  • I have added or updated Storybook if appropriate for my changes

cc @awoods187 @cockroachdb/sql-execution

@asubiotto
Copy link
Contributor Author

asubiotto commented Jan 22, 2021

Also, a note that I don't think this PR builds yet. To do so, I need to merge the protobuf updates I have in #59132, but I'd still appreciate a look. @dhartunian added you as a reviewer, let me know if I should tag someone else.

@Annebirzin
Copy link
Collaborator

@asubiotto I believe we are planning to remove the 'TXN type' column because we now have the transactions page (but we would still add txn type as a filter and include it on the statement detail page) @awoods187 can you confirm?

@awoods187
Copy link

@Annebirzin that matches my understanding.

@asubiotto this is exciting!

@dhartunian
Copy link
Contributor

@asubiotto I published a beta version of the CRDB client from this PR: cockroachdb/cockroach#59132 which you can use to get this to pass build.

If any of the endpoints could return a missing value, you can guard against that using patterns like:

const maxMemUsageBars = [
  bar("max-mem-usage", (d: StatementStatistics) => d.stats.max_mem_usage?.mean),
];

const networkBytesBars = [
  bar(
    "network-bytes",
    (d: StatementStatistics) => d.stats.bytes_sent_over_network?.mean,
  ),
];

With the ? on the field that may be undefined. Documented here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining.

I'll look through code in more detail as well.

@dhartunian
Copy link
Contributor

@asubiotto use 0.0.5-beta.0 as the crdb-protobuf-client version in cluster-ui/package.json

Copy link
Contributor

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

Regarding testing, I think making sure that the Storybook pages for StatementsPage and StatementDetails page components render properly is a good place to start. You can adjust the fixtures in packages/cluster-ui/src/statementsPage/statementsPage.fixture.ts for example to make sure the pages have the input data they need for the new fields.

@asubiotto
Copy link
Contributor Author

Added the fields to the storybook fixture and change the protobuf version to the beta you pushed (thanks). I also had a question about legend formatters. I haven't passed any into the bars I created, is that fine?

@dhartunian
Copy link
Contributor

I think what we'll do is once your CRDB change is merged, we'll publish a new proto version that's non-beta, then we can merge this, and you can bump the cluster-ui dependency version in pkg/ui.

@asubiotto
Copy link
Contributor Author

I think what we'll do is once your CRDB change is merged, we'll publish a new proto version that's non-beta, then we can merge this, and you can bump the cluster-ui dependency version in pkg/ui.

Sounds good.

I fixed the build issue which was caused by my deleting the rows affected title which is still used by the transactions page (for now). Added the .scss back in. Related to this, is there a way to get a tool to yell at you if you're referencing a css class that doesn't exist?

@@ -24,7 +24,7 @@
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to change anything here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, these are overrides for specific column widths in case you need them.

@asubiotto
Copy link
Contributor Author

Looks like there are some test issues which I believe cockroachdb/cockroach#59132 fixes. I'll wait for that to merge.

Also, I see that I'm getting some lint errors and would like to run eslint --fix on save. Have you by any chance set that up in Goland? I tried using an automatic configuration which didn't work due to not being able to find an eslint package. I then tried to link it to both eslint and typescript-eslint in the parent node_modules folder but it complains about the absence of an lib/options folder.

@dhartunian
Copy link
Contributor

I think what we'll do is once your CRDB change is merged, we'll publish a new proto version that's non-beta, then we can merge this, and you can bump the cluster-ui dependency version in pkg/ui.

Sounds good.

I fixed the build issue which was caused by my deleting the rows affected title which is still used by the transactions page (for now). Added the .scss back in. Related to this, is there a way to get a tool to yell at you if you're referencing a css class that doesn't exist?

I don't think such a feature exists. The bar chart code in particular is a bit ugly so it's easier to make mistakes in there. Maybe @nathanstilwell has thoughts.

@dhartunian
Copy link
Contributor

@asubiotto I have this setup for eslint in Goland and it works for this project. You should only have to run eslint and it takes care of using prettier for formatting and parsing typescript.

Screen Shot 2021-01-27 at 1 18 23 PM

Copy link
Contributor

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

I pushed a small update with CSS edits that hopefully help, and I ran yarn lint:fix in a second commit.

@@ -24,7 +24,7 @@
}
}

.statements-table__col-count, .statements-table__col-retries, .statements-table__col-rows {
.statements-table__col-count, .statements-table__col-rows, .statements-table__col-rows-read, .statements-table__col-bytes-read , .statements-table__col-max-mem-usage, .statements-tabe__col-network-bytes, .statements-table__col-retries {
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a tabe -> table spelling error here. I will push a small commit to your branch that cleans this up. It's quite annoying to deal with and we should only need to use a single selector here.

@@ -24,7 +24,7 @@
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nope, these are overrides for specific column widths in case you need them.

@asubiotto
Copy link
Contributor Author

asubiotto commented Jan 28, 2021

Thanks for the edits. Re eslint, I did try that but for some reason it doesn't work (regardless of wheter I'm using ui or cluster-ui project root) and asks me to specify a path to the eslint package. This does work in cockroachdb/cockroach. Will keep on fiddling with it. edit: looks like running yarn remove eslint in cluster-ui has fixed it. I think GoLand might've tried installing its own version which somehow messed things up?

asubiotto and others added 3 commits February 1, 2021 11:22
This commit adds columns for execution stats that we want to display for 21.1.
Namely, this adds rows/bytes read, max memory, and network bytes sent. The
rows affected column has been removed.
The commit also reorders all column-related code to follow the graphical order.
Make bar chart wrapper apply a simple set of
uniform styles instead of mandating a long
list of carefully selected selectors.

Adjust existing width overrides of certain
columns to not refer to the
"name"+`--bar-chart` selector and instead
target the bar charts inside of the specific
table cells. This reduces the need for
named bar chart selectors inside each column.
@asubiotto
Copy link
Contributor Author

New version that points to v0.0.5 protobuf changes and fixes CI errors. I think this should be good to go! PTAL

Copy link
Contributor

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

LGTM.

Once you merge this, an automated build will create and publish the next version of the cluster-ui package. You can then bump the version in CRDB to get the latest version of the statements page. Latest version will be pushed as a git commit with a version number to the repo, or can be seen in npm: https://www.npmjs.com/package/@cockroachlabs/cluster-ui

@asubiotto
Copy link
Contributor Author

Thanks for your guidance!

@asubiotto asubiotto merged commit 449b51c into cockroachdb:master Feb 2, 2021
@asubiotto asubiotto deleted the statements-page branch February 9, 2021 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: add EXPLAIN ANALYZE stats to statements page
4 participants