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

Traces - Gantt chart / Span list rework #2257

Merged
merged 15 commits into from
Dec 5, 2024

Conversation

TackAdam
Copy link
Collaborator

@TackAdam TackAdam commented Nov 18, 2024

Demo:

GanttChart.mp4

Description

Updates to gantt chart:

  1. Added mini map above
  2. Added reset button
  3. Enabled zoom functionality
  4. Added text to right displaying duration
  5. Moved Pie chart above it. Fixed margins for text being cut off. Reformatted the display text.
  6. Fixed resizing issue with side bar being opened.
  7. Fixed text being cut off for left hand labels in the chart.
  8. Enabled any clicks to the left of the bars to trigger service fly-out for selection.

Updates to Span list:

  1. Added additional tab for "Tree view" to see hierarchy.
  2. Fixed resizing issue with side bar being opened or page goin full screen

General fixes:

  1. Made time changes and data source changes trigger a refresh for traces/services.
  2. Made a helper function to replace the broken for EUI data grid fullscreen functionality.

Overall Look:
Screenshot 2024-12-03 at 10 38 21 AM

Tree View:
Screenshot 2024-12-03 at 11 27 38 AM

MiniMap and zoom:

Screen.Recording.2024-12-03.at.11.30.06.AM.mov

Resizing Fix:

Screen.Recording.2024-12-03.at.11.31.07.AM.mov

Issues Resolved

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Adam Tackett <[email protected]>
@ps48
Copy link
Member

ps48 commented Nov 26, 2024

Just a heads up here, while we are mostly getting in good shape with our Traces CI can you please add unit tests and cypress tests for these new workflows and bug fixed workflows?

Thanks!

@TackAdam TackAdam changed the title [WIP][DRAFT] Gantt chart / Span list updates Traces - Gantt chart / Span list rework Dec 2, 2024
Adam Tackett added 2 commits December 2, 2024 15:58
@TackAdam TackAdam marked this pull request as ready for review December 3, 2024 21:36
isFullScreen: boolean;
}

export const FullScreenWrapper: React.FC<FullScreenWrapperProps> = ({
Copy link
Member

Choose a reason for hiding this comment

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

could you add some comments above to explain what it does or why it's needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added above
//EUI Data grid full screen button is currently broken, this is a workaround using overlay mask

@@ -73,6 +73,10 @@ export function TracesContent(props: TracesProps) {
const [includeMetrics, setIncludeMetrics] = useState(false);
const isNavGroupEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled();

useEffect(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes added the new dependencies to the use effect

    startTime,
    endTime,
    props.dataSourceMDSId,

This triggers the refresh

@@ -15,6 +15,8 @@ interface PltProps {
onHoverHandler?: (event: Readonly<Plotly.PlotMouseEvent>) => void;
onUnhoverHandler?: (event: Readonly<Plotly.PlotMouseEvent>) => void;
onClickHandler?: (event: Readonly<Plotly.PlotMouseEvent>) => void;
onSelectedHandler?: (event: Readonly<Plotly.PlotSelectionEvent>) => void;
onRelayout?: (event: any) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be onRelayout?: (event: Readonly<Plotly.PlotSelectionEvent>) => void can refrin from using any as type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

showFullScreenSelector: false,
additionalControls: toolbarButtons,
}}
style={{ height: fullScreenMode ? '100%' : '500px', overflowY: 'auto' }}
Copy link
Member

Choose a reason for hiding this comment

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

Why is the datagrid restricted to 500px when not in fullscreen? Does this change on a bigger screen?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Auto can't be used as the window is initially rendered with the tree collapsed. So the window becomes roughly 50 pixels that is scrollable. 500pixels matches the limit of the "Span Tree" and keeps the window size for that panel consistent.

Comment on lines 610 to 618
position: 'fixed',
top: 0,
left: 0,
width: '100vw',
height: '100vh',
backgroundColor: '#fff',
zIndex: 9999,
display: 'flex',
flexDirection: 'column',
Copy link
Member

Choose a reason for hiding this comment

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

Can add a class here and move the custom styling to index.scss

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added classes and move to scss file

.full-screen-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #fff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.full-screen-close-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10000;
}

.full-screen-content {
  flex: 1 1 auto;
  overflow: auto;
}

Comment on lines 64 to 67
useEffect(() => {
refresh();
}, [startTime, endTime, props.dataSourceMDSId]);

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes added the new dependencies to the use effect

    startTime,
    endTime,
    props.dataSourceMDSId,

This triggers the refresh

Comment on lines 131 to 149
it('handles view toggle button group', () => {
const wrapper = mount(<SpanDetailPanel {...mockProps} />);
const toggleButtons = wrapper.find(EuiButtonGroup);
expect(toggleButtons).toHaveLength(1);

// Verify initial state is 'timeline'
expect(toggleButtons.prop('idSelected')).toBe('timeline');

// Simulate changing the toggle
act(() => {
toggleButtons.prop('onChange')!('span_list');
});

wrapper.update();

// Verify the toggle button group has been updated
const updatedToggleButtons = wrapper.find(EuiButtonGroup);
expect(updatedToggleButtons.prop('idSelected')).toBe('span_list');
});
Copy link
Member

Choose a reason for hiding this comment

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

For this test I feel we are testing the button and not what our page is rendering on button click. The button is already tested in OUI, we should rather test on button change is the rendered component changing to gantt-chart, table or tree view.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the test as this functionality is covered by OUI and the table specific checks should be done in span_detail_table

</div>
);
case 'durationInNanos':
return `${round(nanoToMilliSec(Math.max(0, value)), 2)} ms`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's with the names here, where the column's id says 'nanos' but the function for the render seems to be showing milliseconds, where it calls a method named 'nanoToMilliSec'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept that from the originally implementation which has been in place for 3 years, not sure the original reasoning.
dde9588#diff-491203dc294dcf7e9d988e5ba55b77471fccebc3e7d3d62c42dd0b0a6a365599R136

Signed-off-by: Adam Tackett <[email protected]>
Comment on lines 277 to +285
await act(() => {
ReactDOM.render(
<SpanDetailTable
<SpanDetailTableHierarchy
http={httpClientMock}
hiddenColumns={['traceId', 'traceGroup']}
DSL={{}}
openFlyout={(spanId: string) => setCurrentSpan(spanId)}
mode='data_prepper'
mode="data_prepper"
dataSourceMDSId="testDataSource"
Copy link
Member

Choose a reason for hiding this comment

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

Post snapshot check, we should add some tests to see if expand/collapse is working or not as that is the main functionality of this view.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Covered with added cypress testing as follows:

describe('Testing traces tree view',
it('Verifies tree view and table toggle functionality with expand/collapse logic',
it('Verifies tree view expand arrow functionality',
it('Verifies span flyout',
it('Handles toggling between full screen and regular modes',

Comment on lines +71 to +83
const updateAvailableWidth = () => {
if (containerRef.current) {
setAvailableWidth(containerRef.current.getBoundingClientRect().width);
} else {
setAvailableWidth(window.innerWidth);
}
};

const handleFullScreenChange = () => {
const isFullscreenActive = !!document.fullscreenElement;
setIsFullScreen(isFullscreenActive);
updateAvailableWidth();
};
Copy link
Member

Choose a reason for hiding this comment

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

Nit. I personally don't ride with adding the function definitions inside useEffect(). But is not a blocker.

}, []);

const dynamicLayoutAdjustment = useMemo(() => {
return isLocked ? availableWidth - 350 : availableWidth - 150;
Copy link
Member

Choose a reason for hiding this comment

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

Should this change when new home is enabled/disabled? Is the pixel width of the sidebar constant with and without the new home?

Copy link
Collaborator Author

@TackAdam TackAdam Dec 4, 2024

Choose a reason for hiding this comment

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

Updated:

const dynamicLayoutAdjustment = useMemo(() => {
const newNavigation = coreRefs?.chrome?.navGroup.getNavGroupEnabled?.();
const adjustment = newNavigation ? 350 : 400;
return isLocked ? availableWidth - adjustment : availableWidth - 150;
}, [isLocked, availableWidth]);

Comment on lines +419 to +427
onRelayout={(event) => {
// Handle x-axis range update
if (event && event['xaxis.range[0]'] && event['xaxis.range[1]']) {
const newRange = [event['xaxis.range[0]'], event['xaxis.range[1]']];
setSelectedRange(newRange);
} else {
setSelectedRange(fullRange);
}
}}
Copy link
Member

Choose a reason for hiding this comment

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

Nit - not blocking. Just for good readability do you want to follow how other props functions are declared and used here. Something like onClick.

Comment on lines +338 to +345
interface Span {
spanId: string;
parentSpanId?: string;
children: Span[];
[key: string]: any;
}

type SpanMap = Record<string, Span>;
Copy link
Member

Choose a reason for hiding this comment

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

Adam Tackett added 2 commits December 4, 2024 16:10
Signed-off-by: Adam Tackett <[email protected]>
Signed-off-by: Adam Tackett <[email protected]>
Copy link
Member

@ps48 ps48 left a comment

Choose a reason for hiding this comment

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

Can see the cypress tests passed! Thanks for the changes. The non-blocking changes can be done in the upcoming PRs.

@TackAdam TackAdam merged commit ab396b9 into opensearch-project:main Dec 5, 2024
14 of 18 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/dashboards-observability/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/dashboards-observability/backport-2.x
# Create a new branch
git switch --create backport/backport-2257-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ab396b94a14f922220e5ec071bc4f696208650b3
# Push it to GitHub
git push --set-upstream origin backport/backport-2257-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/dashboards-observability/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-2257-to-2.x.

TackAdam added a commit to TackAdam/dashboards-observability that referenced this pull request Dec 6, 2024
* fix refresh on timepicker change, update gannt chart, mini map, span list nesting

Signed-off-by: Adam Tackett <[email protected]>

* ui changes and new tab for spans

Signed-off-by: Adam Tackett <[email protected]>

* ui updates, additional bug fixes

Signed-off-by: Adam Tackett <[email protected]>

* add eui grid full screen, testing

Signed-off-by: Adam Tackett <[email protected]>

* add back table height for tree, cap left margin

Signed-off-by: Adam Tackett <[email protected]>

* add some jest testing

Signed-off-by: Adam Tackett <[email protected]>

* address comments

Signed-off-by: Adam Tackett <[email protected]>

* test

Signed-off-by: Adam Tackett <[email protected]>

* test remove

Signed-off-by: Adam Tackett <[email protected]>

* add cypress testing, conditional check for new nav

Signed-off-by: Adam Tackett <[email protected]>

* fix width of tables

Signed-off-by: Adam Tackett <[email protected]>

---------

Signed-off-by: Adam Tackett <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
(cherry picked from commit ab396b9)
TackAdam added a commit that referenced this pull request Dec 6, 2024
…ework (#2283)

* Traces - Gantt chart / Span list rework (#2257)

* fix refresh on timepicker change, update gannt chart, mini map, span list nesting

Signed-off-by: Adam Tackett <[email protected]>

* ui changes and new tab for spans

Signed-off-by: Adam Tackett <[email protected]>

* ui updates, additional bug fixes

Signed-off-by: Adam Tackett <[email protected]>

* add eui grid full screen, testing

Signed-off-by: Adam Tackett <[email protected]>

* add back table height for tree, cap left margin

Signed-off-by: Adam Tackett <[email protected]>

* add some jest testing

Signed-off-by: Adam Tackett <[email protected]>

* address comments

Signed-off-by: Adam Tackett <[email protected]>

* test

Signed-off-by: Adam Tackett <[email protected]>

* test remove

Signed-off-by: Adam Tackett <[email protected]>

* add cypress testing, conditional check for new nav

Signed-off-by: Adam Tackett <[email protected]>

* fix width of tables

Signed-off-by: Adam Tackett <[email protected]>

---------

Signed-off-by: Adam Tackett <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
(cherry picked from commit ab396b9)

* fix loaddash error, update snapshots

Signed-off-by: Adam Tackett <[email protected]>

* add missing format change

Signed-off-by: Adam Tackett <[email protected]>

---------

Signed-off-by: Adam Tackett <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
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.

4 participants