Skip to content

[APM] React flow service map#248521

Draft
jennypavlova wants to merge 29 commits intoelastic:mainfrom
jennypavlova:react-flow-service-map
Draft

[APM] React flow service map#248521
jennypavlova wants to merge 29 commits intoelastic:mainfrom
jennypavlova:react-flow-service-map

Conversation

@jennypavlova
Copy link
Member

@jennypavlova jennypavlova commented Jan 9, 2026

Summary

This PR introduces a proof of concept to evaluate replacing Cytoscape.js with React Flow for the APM Service Map visualization.
The React Flow version is behind a feature flag and appears as a new "React Flow Service map" tab next to the existing Service Map.

  • Overview:
image
  • Node Selection
image
  • Zoomed
image
  • Orientation switching
Horizontal Vertical
image image

Why React Flow?

React Flow renders actual DOM elements (not canvas), making it more accessible and easier to work with using standard React patterns. It also has a smaller bundle size (~150KB vs ~500KB) and a more intuitive API for creating custom nodes.

What's Implemented

✅ Custom ServiceNode component (circular with agent icons)
✅ Custom DependencyNode component (diamond with span icons)
✅ Dagre-based left-to-right layout matching Cytoscape
✅ Edge highlighting on node click (blue edges + arrows)
✅ Data transformation from Cytoscape format to React Flow
✅ Feature flag xpack.apm.featureFlags.serviceMapUseReactFlow
✅ Unit tests for transformElements and applyLayout

What's NOT implemented (future work):

❌ Code optimizations around the node/edges highlighting
❌ Dark mode support for controls and background and other styling improvements
❌ Popover on node click with service stats/links
❌ Grouped "externals" connections
❌ Keyboard navigation
❌ Performance testing with large maps
❌ E2E tests

How to test:

  • Add xpack.apm.featureFlags.serviceMapUseReactFlow: true to kibana.dev.yml
  • Navigate to APM
  • Click the "React Flow Service map" tab

@jennypavlova jennypavlova self-assigned this Jan 9, 2026
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!

* Transform Cytoscape elements to React Flow format
* Converts nodes and edges from Cytoscape's data structure to React Flow's format
*/
export function transformElements(
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this format be returned by getServiceMapNodes in the future?

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, ideally the API should return the react flow format. For the purpose of the PoC we have this function to help us work with the data we have and if we decide to proceed with this solution we should remove this and return the data in the correct format.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the idea for now was to use the already existing structure for the format, just for the POC, when we implement this we will get the proper data for the flow without using any cytoscape transform

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 added a comment before the function to explain that

@crespocarlos
Copy link
Contributor

Is it possible to centralize the node with the arrow?

image

@jennypavlova
Copy link
Member Author

Is it possible to centralize the node with the arrow?

I think now it is the center of the node + text as I made them flex items, but yes I will try to fix the position, thanks for spotting that

@jennypavlova
Copy link
Member Author

Is it possible to centralize the node with the arrow?

@crespocarlos Fixed in Fix edges position

image

…d-collapse

[PoC] React flow service map expand collapse
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.

[Deliverable][POC] Service Map : replace cytoscape with react flow

4 participants