Skip to content

Add with-source flag to top#1614

Merged
adleong merged 3 commits intomasterfrom
alex/top-source
Sep 11, 2018
Merged

Add with-source flag to top#1614
adleong merged 3 commits intomasterfrom
alex/top-source

Conversation

@adleong
Copy link
Member

@adleong adleong commented Sep 8, 2018

Fixes #1593

Add a --with-source flag to linkerd top which defaults to true. Setting this to false remove the source column from the output.

Here is an example of the difference when the emojivoto demo is used with the vote-bot deployment scaled up to 3 pods:

linkerd top -n emojivoto deploy/web
(press q to quit)

Source                  Destination             Path                                                    Count  Best   Worst  Last   Success Rate
web-c6775f4c8-z6pvh     emoji-b59755f8d-7bwsb   /emojivoto.v1.EmojiService/ListAll                      33     1ms    11ms   5ms    100.00%
web-c6775f4c8-z6pvh     emoji-b59755f8d-7bwsb   /emojivoto.v1.EmojiService/FindByShortcode              33     1ms    20ms   4ms    100.00%
vote-bot-5976d69bc6-h66wweb-c6775f4c8-z6pvh     /api/list                                               11     4ms    16ms   8ms    100.00%
vote-bot-5976d69bc6-h66wweb-c6775f4c8-z6pvh     /api/vote                                               11     6ms    26ms   14ms   81.82%
vote-bot-5976d69bc6-rwtkweb-c6775f4c8-z6pvh     /api/list                                               11     5ms    15ms   15ms   100.00%
vote-bot-5976d69bc6-rwtkweb-c6775f4c8-z6pvh     /api/vote                                               11     6ms    35ms   35ms   72.73%
vote-bot-5976d69bc6-wkj2web-c6775f4c8-z6pvh     /api/list                                               11     4ms    15ms   14ms   100.00%
vote-bot-5976d69bc6-wkj2web-c6775f4c8-z6pvh     /api/vote                                               11     6ms    63ms   28ms   100.00%
web-c6775f4c8-z6pvh     voting-597f647876-n2p89 /emojivoto.v1.VotingService/VoteDoughnut                6      2ms    11ms   4ms    100.00%
web-c6775f4c8-z6pvh     voting-597f647876-n2p89 /emojivoto.v1.VotingService/VotePoop                    5      2ms    7ms    3ms    0.00%
web-c6775f4c8-z6pvh     voting-597f647876-n2p89 /emojivoto.v1.VotingService/VoteThumbsup                2      4ms    7ms    7ms    100.00%
linkerd top -n emojivoto deploy/web --with-source=false
(press q to quit)

Destination             Path                                                    Count  Best   Worst  Last   Success Rate
emoji-b59755f8d-7bwsb   /emojivoto.v1.EmojiService/ListAll                      83     869µs  27ms   2ms    100.00%
web-c6775f4c8-z6pvh     /api/list                                               83     2ms    53ms   5ms    100.00%
emoji-b59755f8d-7bwsb   /emojivoto.v1.EmojiService/FindByShortcode              83     640µs  10ms   1ms    100.00%
web-c6775f4c8-z6pvh     /api/vote                                               83     5ms    54ms   13ms   75.90%
voting-597f647876-n2p89 /emojivoto.v1.VotingService/VotePoop                    20     1ms    10ms   5ms    0.00%
voting-597f647876-n2p89 /emojivoto.v1.VotingService/VoteDoughnut                14     2ms    5ms    3ms    100.00%
voting-597f647876-n2p89 /emojivoto.v1.VotingService/VoteClap                    3      2ms    5ms    2ms    100.00%
voting-597f647876-n2p89 /emojivoto.v1.VotingService/VoteBulb                    2      5ms    6ms    5ms    100.00%

Signed-off-by: Alex Leong [email protected]

Copy link
Member

@siggy siggy 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!

cli/cmd/top.go Outdated
if row.by == by && row.source == source && row.destination == destination {
match := row.by == by && row.destination == destination
if withSource {
match = row.by == by && row.source == source && row.destination == destination
Copy link
Member

Choose a reason for hiding this comment

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

maybe match = match && row.source == source slightly clearer?

...or, a big ol' one-liner...

if row.by == by && row.destination == destination && (row.source == source || !withSource)

tbprint(0, 0, "(press q to quit)")
x := 0
for i, header := range columnNames {
if i == 0 && !withSource {
Copy link
Member

Choose a reason for hiding this comment

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

consider:

if header == "Source" && !withSource {

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is kinda brittle either way (brittle to changing the header string vs brittle to reordering the columns) so I'd lean towards keeping it the way it is.

Signed-off-by: Alex Leong <[email protected]>
Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

The implementation looks good. I just had one comment about the flag itself.

cli/cmd/top.go Outdated
"Display requests with this :authority")
cmd.PersistentFlags().StringVar(&options.path, "path", options.path,
"Display requests with paths that start with this prefix")
cmd.PersistentFlags().BoolVar(&options.withSource, "with-source", options.withSource, "Include the source column")
Copy link
Contributor

Choose a reason for hiding this comment

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

I find boolean flags that default to true to be awkward to use from a command line perspective, since they require a boolean value to disable. For instance, to suppress the source column, you would need to run:

linkerd top --with-source=false

Whereas if the flag were defaulted to false, then you could run:

linkerd top --hide-sources

Or whatever you'd choose to call it in that case.

Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

⭐️ Realized I didn't click Approve with my previous review. I didn't mean for that comment to be a blocker.

Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

⭐️ Great, thanks for updating!

@adleong adleong merged commit bd15482 into master Sep 11, 2018
@adleong adleong deleted the alex/top-source branch September 11, 2018 21:21
zachalbert added a commit to zachalbert/linkerd2 that referenced this pull request Sep 13, 2018
* master:
  Update CHANGES.md for v18.9.1 release (linkerd#1631)
  Cleanly shutdown tap stream to data plane proxies (linkerd#1624)
  Change breadcrumb header to default font in styles.css (linkerd#1633)
  Improve top table to better cope with high RPS traffic (linkerd#1634)
  Add small success rate chart to table, misc web tweaks (linkerd#1628)
  Consolidate the source and destination columns in the Tap and Top tables (linkerd#1620)
  remove extraneous calc function in sidebar.css (linkerd#1632)
  Display more helpful websocket errors (linkerd#1626)
  Add breadcrumb navigation at the top of linkerd dashboard (linkerd#1613)
  Introduce inject check for known sidecars (linkerd#1619)
  Bump Prometheus to v2.4.0, Grafana to 5.2.4 (linkerd#1625)
  Improve performance of tap table by throttling updates (linkerd#1623)
  Add with-source flag to top (linkerd#1614)

Conflicts:
	web/app/css/styles.css
	web/app/js/components/ResourceDetail.jsx
	web/app/js/index.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants