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

Trace analytics ui bug fixes in custom sources #2162

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -418,7 +418,7 @@ exports[`Search bar components renders search bar 1`] = `
isClearable={false}
isLoading={false}
onChange={[Function]}
onSearch={[MockFunction]}
onSearch={[Function]}
placeholder="Trace ID, trace group name, service name"
prepend={
<GlobalFilterButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,16 @@
}

const averageLatency = `Average duration: ${
map[service].latency! >= 0 ? map[service].latency + 'ms' : 'N/A'
map[service].latency! >= 0 ? map[service].latency + 'ms' : '-'
}`;

const errorRate = `Error rate: ${
map[service].error_rate! >= 0 ? map[service].error_rate + '%' : 'N/A'
map[service].error_rate! >= 0 ? map[service].error_rate + '%' : '-'
}`;

const throughput =
(map[service].throughput! >= 0 ? `Request rate: ${map[service].throughput}` : 'N/A') +
'Request rate: ' +
(map[service].throughput! >= 0 ? `${map[service].throughput}` : '-') +
(map[service].throughputPerMinute ? ` (${map[service].throughputPerMinute} per minute)` : '');

const hover = `${service}\n\n ${averageLatency} \n ${errorRate} \n ${throughput}`;
Expand Down Expand Up @@ -323,7 +324,7 @@
percentileMaps: Array<{ traceGroupName: string; durationFilter: { gte?: number; lte?: number } }>,
conditionString: string // >= 95th, < 95th
): FilterType => {
const DSL: any = {

Check warning on line 327 in public/components/trace_analytics/components/common/helper_functions.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
query: {
bool: {
must: [],
Expand Down Expand Up @@ -368,12 +369,12 @@
mode: TraceAnalyticsMode,
filters: FilterType[],
query: string,
startTime: any,

Check warning on line 372 in public/components/trace_analytics/components/common/helper_functions.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
endTime: any,

Check warning on line 373 in public/components/trace_analytics/components/common/helper_functions.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
page?: string,
appConfigs: FilterType[] = []
) => {
const DSL: any = {

Check warning on line 377 in public/components/trace_analytics/components/common/helper_functions.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
query: {
bool: {
must: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

export interface ServiceObject {
[key: string]: {
average_latency: any;

Check warning on line 34 in public/components/trace_analytics/components/common/plots/service_map.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
serviceName: string;
id: number;
traceGroups: Array<{ traceGroup: string; targetResource: string[] }>;
Expand Down Expand Up @@ -77,7 +77,7 @@
const [invalid, setInvalid] = useState(false);
const [network, setNetwork] = useState(null);
const [ticks, setTicks] = useState<number[]>([]);
const [items, setItems] = useState<any>({});

Check warning on line 80 in public/components/trace_analytics/components/common/plots/service_map.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [query, setQuery] = useState('');
const toggleButtons = [
{
Expand All @@ -96,9 +96,9 @@

const [selectedNodeDetails, setSelectedNodeDetails] = useState<ServiceNodeDetails | null>(null);

const [selectableValue, setSelectableValue] = useState<Array<EuiSuperSelectOption<any>>>([]);

Check warning on line 99 in public/components/trace_analytics/components/common/plots/service_map.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

const onChangeSelectable = (value: React.SetStateAction<Array<EuiSuperSelectOption<any>>>) => {

Check warning on line 101 in public/components/trace_analytics/components/common/plots/service_map.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
// if the change is changing for the first time then callback servicemap with metrics
if (selectableValue.length === 0 && value.length !== 0) {
if (includeMetricsCallback) {
Expand All @@ -109,7 +109,7 @@
setSelectableValue(value);
};

const metricOptions: Array<EuiSuperSelectOption<any>> = [

Check warning on line 112 in public/components/trace_analytics/components/common/plots/service_map.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
{
value: 'latency',
inputDisplay: 'Duration',
Expand Down Expand Up @@ -190,6 +190,11 @@
throughput: selectedNode.throughput,
};

// On traces page with custom sources
// When user clicks on empty graph, load metrics
if (selectableValue.length === 0) {
onChangeSelectable('latency');
}
// Update the state to display node details
setSelectedNodeDetails(details);
}
Expand All @@ -197,7 +202,7 @@
hoverNode: (_event) => {},
};

const onFocus = (service: string, networkInstance?: any) => {

Check warning on line 205 in public/components/trace_analytics/components/common/plots/service_map.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (service.length === 0) {
setInvalid(false);
} else if (serviceMap[service]) {
Expand All @@ -209,6 +214,21 @@
}
};

useEffect(() => {
if (selectedNodeDetails) {
const selectedNode = items?.graph.nodes.find(
(node) => node.label === selectedNodeDetails.label
);
const details = {
label: selectedNode.label,
average_latency: selectedNode.average_latency,
error_rate: selectedNode.error_rate,
throughput: selectedNode.throughput,
};
setSelectedNodeDetails(details);
}
}, [items]);

useEffect(() => {
if (Object.keys(serviceMap).length === 0) return;
const values = Object.keys(serviceMap)
Expand All @@ -228,7 +248,6 @@
filterByCurrService
)
);
setSelectedNodeDetails(null);
}, [serviceMap, idSelected]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
*/

import {
EuiButtonIcon,
EuiCompressedFieldSearch,
EuiFlexGroup,
EuiFlexItem,
EuiSuperDatePicker,
EuiButtonIcon,
EuiCompressedFieldSearch,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import debounce from 'lodash/debounce';
import React, { forwardRef, useImperativeHandle, useState } from 'react';
import { i18n } from '@osd/i18n';
import { uiSettingsService } from '../../../../../common/utils';
import { FiltersProps } from './filters/filters';
import { GlobalFilterButton } from './filters/filters';
import { FiltersProps, GlobalFilterButton } from './filters/filters';

export const renderDatePicker = (
startTime: string,
Expand Down Expand Up @@ -87,7 +86,7 @@ export const SearchBar = forwardRef((props: SearchBarOwnProps, ref) => {
setQuery(e.target.value);
setGlobalQuery(e.target.value);
}}
onSearch={props.refresh}
onSearch={(searchQuery) => props.refresh(undefined, searchQuery)}
/>
</EuiFlexItem>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ export const ServicesList = ({
const [options, setOptions] = useState<Array<{ label: string }>>([]);

const nameColumnAction = (serviceName: string) => {
if (addFilter) {
addFilter({
field: 'serviceName',
operator: 'is',
value: serviceName,
inverted: false,
disabled: false,
});
setFilteredService(serviceName);
if (!addFilter) return;
addFilter({
field: 'serviceName',
operator: 'is',
value: serviceName,
inverted: false,
disabled: false,
});
setFilteredService(serviceName);
setTimeout(function () {
window.scrollTo({ left: 0, top: 0, behavior: 'smooth' });
}
}, 500);
};

const titleBar = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function TracesContent(props: TracesProps) {
chrome,
query,
filters,
appConfigs,
appConfigs = [],
startTime,
endTime,
childBreadcrumbs,
Expand Down Expand Up @@ -131,12 +131,13 @@ export function TracesContent(props: TracesProps) {
setFilters(newFilters);
};

const refresh = async (sort?: PropertySort) => {
const refresh = async (sort?: PropertySort, overrideQuery?: string) => {
const filterQuery = overrideQuery ?? query;
setLoading(true);
const DSL = filtersToDsl(
mode,
filters,
query,
filterQuery,
processTimeStamp(startTime, mode),
processTimeStamp(endTime, mode),
page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ export const getCustomIndicesTracesQuery = (
must_not: [],
},
},
...(sort && { sort: [{ [sort.field]: { order: sort.direction } }] }),
...(sort ? { sort: [{ [sort.field]: { order: sort.direction } }] } : {}),
ps48 marked this conversation as resolved.
Show resolved Hide resolved
track_total_hits: false,
};
if (traceId) {
Expand Down
Loading