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

[Backport 2.17] Update trace analytics landing page to traces and header bug fix #2127

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exports[`Service view component renders service view 1`] = `
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer
size="xl"
size="m"
/>
<EuiPanel>
<PanelTitle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
import { dataSourceFilterFn } from '../../../../../common/utils/shared';
import { coreRefs } from '../../../../framework/core_refs';
import { HeaderControlledComponentsWrapper } from '../../../../plugin_helpers/plugin_headerControl';
import { TraceAnalyticsComponentDeps } from '../../home';
import {
handleServiceMapRequest,
Expand All @@ -64,7 +65,7 @@

export function ServiceView(props: ServiceViewProps) {
const { mode, page, setCurrentSelectedService } = props;
const [fields, setFields] = useState<any>({});

Check warning on line 68 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [serviceMap, setServiceMap] = useState<ServiceObject>({});
const [serviceMapIdSelected, setServiceMapIdSelected] = useState<
'latency' | 'error_rate' | 'throughput'
Expand Down Expand Up @@ -107,7 +108,7 @@
props.parentBreadcrumb,
{
text: 'Trace analytics',
href: '#/services',
href: '#/traces',
},
],
[
Expand Down Expand Up @@ -207,6 +208,12 @@
},
];

const serviceHeader = (
<EuiText size="s">
<h1 className="overview-content">{props.serviceName}</h1>
</EuiText>
);

const renderTitle = (
serviceName: string,
startTime: SearchBarProps['startTime'],
Expand All @@ -221,11 +228,7 @@
{_page === 'serviceFlyout' ? (
<EuiFlyoutHeader hasBorder>
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem>
<EuiText size="s">
<h2 className="overview-content">{serviceName}</h2>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>{serviceHeader}</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiPopover
panelPaddingSize="none"
Expand All @@ -239,13 +242,13 @@
</EuiFlexGroup>
{renderDatePicker(startTime, setStartTime, endTime, setEndTime)}
</EuiFlyoutHeader>
) : coreRefs?.chrome?.navGroup.getNavGroupEnabled() ? (
<HeaderControlledComponentsWrapper
components={[renderDatePicker(startTime, setStartTime, endTime, setEndTime)]}
/>
) : (
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem>
<EuiText size="s">
<h1 className="overview-content">{serviceName}</h1>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>{serviceHeader}</EuiFlexItem>
<EuiFlexItem grow={false}>
{renderDatePicker(startTime, setStartTime, endTime, setEndTime)}
</EuiFlexItem>
Expand Down Expand Up @@ -388,12 +391,12 @@

const [currentSpan, setCurrentSpan] = useState('');
const storedFilters = sessionStorage.getItem('TraceAnalyticsSpanFilters');
const [spanFilters, setSpanFilters] = useState<Array<{ field: string; value: any }>>(

Check warning on line 394 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
storedFilters ? JSON.parse(storedFilters) : []
);
const [DSL, setDSL] = useState<any>({});

Check warning on line 397 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

const setSpanFiltersWithStorage = (newFilters: Array<{ field: string; value: any }>) => {

Check warning on line 399 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
setSpanFilters(newFilters);
sessionStorage.setItem('TraceAnalyticsSpanFilters', JSON.stringify(newFilters));
};
Expand Down Expand Up @@ -431,7 +434,7 @@
setDSL(spanDSL);
}, [props.startTime, props.endTime, props.serviceName, spanFilters]);

const addSpanFilter = (field: string, value: any) => {

Check warning on line 437 in public/components/trace_analytics/components/services/service_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const newFilters = [...spanFilters];
const index = newFilters.findIndex(({ field: filterField }) => field === filterField);
if (index === -1) {
Expand Down Expand Up @@ -489,7 +492,7 @@
results are filtered by {activeFilters.map((filter) => filter.field).join(', ')}
</EuiText>
)}
<EuiSpacer size="xl" />
<EuiSpacer size="m" />
{overview}

{mode === 'data_prepper' || mode === 'custom_data_prepper' ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
};
const DataSourceMenu = props.dataSourceManagement?.ui?.getDataSourceMenu<DataSourceViewConfig>();

const renderOverview = (fields: any) => {

Check warning on line 72 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return (
<EuiPanel>
<PanelTitle title="Overview" />
Expand Down Expand Up @@ -157,7 +157,7 @@
const [serviceBreakdownData, setServiceBreakdownData] = useState([]);
const [payloadData, setPayloadData] = useState('');
const [colorMap, setColorMap] = useState({});
const [ganttData, setGanttData] = useState<{ gantt: any[]; table: any[]; ganttMaxX: number }>({

Check warning on line 160 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 160 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
gantt: [],
table: [],
ganttMaxX: 0,
Expand Down Expand Up @@ -206,8 +206,8 @@

useEffect(() => {
if (!Object.keys(serviceMap).length || !ganttData.table.length) return;
const services: any = {};

Check warning on line 209 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
ganttData.table.forEach((service: any) => {

Check warning on line 210 in public/components/trace_analytics/components/traces/trace_view.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (!services[service.service_name]) {
services[service.service_name] = {
latency: 0,
Expand Down Expand Up @@ -242,7 +242,7 @@
props.parentBreadcrumb,
{
text: 'Trace analytics',
href: '#/services',
href: '#/traces',
},
],
[
Expand Down
10 changes: 6 additions & 4 deletions public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ export const Home = (props: HomeProps) => {

const [dataSourceMDSId, setDataSourceMDSId] = useState([{ id: '', label: '' }]);
const [currentSelectedService, setCurrentSelectedService] = useState('');
let defaultRoute = props.defaultRoute ?? '/services';
const currentHash = window.location.hash.split('#')[1] || '';

// Navigate a valid routes when suffixed with '/traces' and '/services'
// Route defaults to traces page
let defaultRoute = props.defaultRoute ?? '/traces';
const currentHash = window.location.hash.split('#')[1] || '';
if (currentHash.startsWith('/traces') || currentHash.startsWith('/services')) {
defaultRoute = currentHash;
}
Expand Down Expand Up @@ -203,7 +205,7 @@ export const Home = (props: HomeProps) => {
? [
{
text: 'Trace analytics',
href: '#/services',
href: '#/traces',
},
]
: []),
Expand All @@ -218,7 +220,7 @@ export const Home = (props: HomeProps) => {
? [
{
text: 'Trace analytics',
href: '#/services',
href: '#/traces',
},
]
: []),
Expand Down
18 changes: 9 additions & 9 deletions public/components/trace_analytics/trace_side_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import React from 'react';

export function TraceSideBar(props: { children: React.ReactNode }) {
function setIsSelected(items: Array<EuiSideNavItemType<React.ReactNode>>, hash: string): boolean {
if (hash === '#/traces') {
items[0].items[1].isSelected = true;
if (hash === '#/traces' || hash === '#/') {
items[0].items[0].isSelected = true;
return true;
}
if (hash === '#/services' || hash === '#/') {
items[0].items[0].isSelected = true;
if (hash === '#/services') {
items[0].items[1].isSelected = true;
return true;
}
}
Expand All @@ -30,17 +30,17 @@ export function TraceSideBar(props: { children: React.ReactNode }) {
{
name: 'Trace analytics',
id: 1,
href: '#/services',
href: '#/traces',
items: [
{
name: 'Services',
name: 'Traces',
id: 1.1,
href: '#/services',
href: '#/traces',
},
{
name: 'Traces',
name: 'Services',
id: 1.2,
href: '#/traces',
href: '#/services',
},
],
},
Expand Down
Loading