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

[APM] Service Map Layout #59020

Merged
merged 4 commits into from
Mar 4, 2020
Merged

Conversation

ogupte
Copy link
Contributor

@ogupte ogupte commented Mar 2, 2020

Addresses #55544:

  • uses the core breadthfirst cytoscape layout
  • rotates elements by -90degrees
  • selects rum nodes as roots
  • implements hover styles to show connected nodes
  • connects nodes with taxi-style edges
  • fixes flash of unstyled cytoscape elements on initial load
  • moves nodes closer to each other
    service-maps-layout-3

@ogupte ogupte added release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Mar 2, 2020
@ogupte ogupte requested review from smith and formgeist March 2, 2020 12:33
@ogupte ogupte requested a review from a team as a code owner March 2, 2020 12:33
@formgeist
Copy link
Contributor

First of all, this looks amazing @ogupte 🎉 Much better-looking layout for the maps. I've got a few comments and questions;

  • Is it possible that we can decrease the "distance" between each node in the layout? Right now the margin around each node seems big and results in a very zoomed out view at the default level.
  • The hovered highlights look great!
  • The placement of the apm-server in your example, would it be possible to place below the client? I remember we discussed that in the last sync, because having it before the client would be a little confusing.

I would love to see this with another dataset to see how it will display the nodes etc.

Copy link
Contributor

@formgeist formgeist left a comment

Choose a reason for hiding this comment

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

Apart from my comments, I think this is a definite improvement over the existing map layout.

Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

I have some suggestions but nothing blocking. Agree with @formgeist's comments too.

Great work!

tenor-218926653

)
.addParameters({
options: {
// theme: create({
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these comments?

}
];

export const cytoscapeOptions: cytoscape.CytoscapeOptions = {
autoungrabify: true,
boxSelectionEnabled: false,
layout,
// layout,
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this comment?

@@ -75,7 +71,10 @@ const style: cytoscape.Stylesheet[] = [
{
selector: 'edge',
style: {
'curve-style': 'bezier',
// 'curve-style': 'bezier',
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this comment

cy.removeListener('mouseover', 'edge, node', mouseoverHandler);
cy.removeListener('mouseout', 'edge, node', mouseoutHandler);
}
};
}, [cy, serviceName]);
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we disabling exhaustive deps here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was able to rearrange the code to safely remove this

animationEasing: animationOptions.easing,
animationDuration: animationOptions.duration,
// Rotate nodes from top -> bottom to display left -> right
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

You can put a description of why we're ignoring something after the @ts-ignore on the same line comment.

Copy link
Member

Choose a reason for hiding this comment

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

@smith great idea.
What about opening a PR to fix the types and link to that in the comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sqren I'll just wait until this is merged and open a PR that updates the types and removes the comments that can be removed.

// Set up cytoscape event handlers
useEffect(() => {
const dataHandler: cytoscape.EventHandler = event => {
const dataHandler = useCallback(
Copy link
Contributor

Choose a reason for hiding this comment

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

The typing of this with the extra argument is weird now, so I think maybe there should be two functions, one that actually is an EventHandler (that you can type with useCallback<cytoscape.EventHandler> and the one that takes the extra argument that gets wrapped.

It's not a big thing, but I'd rather have more verbose code than confusing types.

function isService(el: cytoscape.NodeSingular) {
return el.data('type') === 'service';
}

const style: cytoscape.Stylesheet[] = [
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

If we update to the latest @types/cytoscape some of these will go away. We should. I know visibility is in there as of the latest.

@@ -75,7 +71,10 @@ const style: cytoscape.Stylesheet[] = [
{
selector: 'edge',
style: {
'curve-style': 'bezier',
// 'curve-style': 'bezier',
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment.

@@ -8,13 +8,17 @@ import { useWindowSize } from 'react-use';

export function useRefHeight(): [
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably should be renamed to something like useRefDimensions since it gets height and width now.


const height = ref.current ? windowHeight - topOffset : 0;

return [ref, height];
return [ref, height, width];
}
Copy link
Member

@sorenlouv sorenlouv Mar 2, 2020

Choose a reason for hiding this comment

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

A quick scan: looks like it would be more clear to return the default value early and the conditionals disappear (untested):

export function useRefHeight(): [
  MutableRefObject<HTMLDivElement | null>,
  number,
  number
] {
  const ref = useRef<HTMLDivElement>(null);

  if (!ref.current) {
    return [ref, 0, 0];
  }

  const windowHeight = useWindowSize().height;
  const { top, width } = ref.current.getBoundingClientRect();
  const height = windowHeight - top;

  return [ref, height, width];
}

Btw what do you think about returning an object similar to how useWindowSize works?

return { ref, height, width };

ogupte added 3 commits March 2, 2020 23:37
- uses the core breadthfirst cytoscape layout
- rotates elements by -90degrees
- selects rum nodes as roots
- implements hover styles to show connected nodes
- fixes flash of unstyled cytoscape elements on initial load
@ogupte ogupte force-pushed the apm-55544-service-map-layout branch from 56153da to e8d955e Compare March 3, 2020 07:48
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@ogupte ogupte merged commit 5539d69 into elastic:master Mar 4, 2020
ogupte added a commit to ogupte/kibana that referenced this pull request Mar 4, 2020
* Addresses elastic#55544.
- uses the core breadthfirst cytoscape layout
- rotates elements by -90degrees
- selects rum nodes as roots
- implements hover styles to show connected nodes
- fixes flash of unstyled cytoscape elements on initial load

* PR review feedback

* adds canned response for testing cytoscape layout in storybook

* update dep snapshot for removing cytoscape-dagre
ogupte added a commit that referenced this pull request Mar 4, 2020
* Addresses #55544.
- uses the core breadthfirst cytoscape layout
- rotates elements by -90degrees
- selects rum nodes as roots
- implements hover styles to show connected nodes
- fixes flash of unstyled cytoscape elements on initial load

* PR review feedback

* adds canned response for testing cytoscape layout in storybook

* update dep snapshot for removing cytoscape-dagre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants