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

Update traces span redirection #2201

Merged
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 @@ -28,11 +28,6 @@
import React, { useEffect, useMemo, useState } from 'react';
import { DataSourceManagementPluginSetup } from '../../../../../../../src/plugins/data_source_management/public';
import { DataSourceOption } from '../../../../../../../src/plugins/data_source_management/public/components/data_source_menu/types';
import {
DEFAULT_DATA_SOURCE_NAME,
DEFAULT_DATA_SOURCE_TYPE,
} from '../../../../../common/constants/data_sources';
import { observabilityLogsID } from '../../../../../common/constants/shared';
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
import { coreRefs } from '../../../../framework/core_refs';
import { HeaderControlledComponentsWrapper } from '../../../../plugin_helpers/plugin_headerControl';
Expand Down Expand Up @@ -66,7 +61,7 @@

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

Check warning on line 64 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 @@ -177,15 +172,16 @@
name: 'View logs',
'data-test-subj': 'viewLogsButton',
onClick: () => {
coreRefs?.application!.navigateToApp(observabilityLogsID, {
path: `#/explorer`,
state: {
DEFAULT_DATA_SOURCE_NAME,
DEFAULT_DATA_SOURCE_TYPE,
queryToRun: `source = ss4o_logs-* | where serviceName='${props.serviceName}'`,
startTimeRange: props.startTime,
endTimeRange: props.endTime,
},
coreRefs?.application!.navigateToApp('data-explorer', {
path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:${
props.startTime
},to:${props.endTime}))&_q=(filters:!(),query:(dataset:(dataSource:(id:'${
props.dataSourceMDSId[0].id ?? ''
}',title:'',type:DATA_SOURCE),id:'${
props.dataSourceMDSId[0].id
}::ss4o_logs-*',timeFieldName:'%40timestamp',title:'ss4o_logs-*',type:INDEXES),language:PPL,query:'source%20%3D%20ss4o_logs-*%20%7C%20where%20serviceName%20%3D%20${
props.serviceName
}'))`,
});
},
},
Expand Down Expand Up @@ -380,12 +376,12 @@

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

Check warning on line 379 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 382 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 384 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 @@ -423,7 +419,7 @@
setDSL(spanDSL);
}, [props.startTime, props.endTime, props.serviceName, spanFilters]);

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

Check warning on line 422 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
import moment from 'moment';
import React, { useEffect, useState } from 'react';
import { HttpSetup } from '../../../../../../../src/core/public';
import {
DEFAULT_DATA_SOURCE_NAME,
DEFAULT_DATA_SOURCE_TYPE,
} from '../../../../../common/constants/data_sources';
import { observabilityLogsID } from '../../../../../common/constants/shared';
import { TRACE_ANALYTICS_DATE_FORMAT } from '../../../../../common/constants/trace_analytics';
import { SpanField, TraceAnalyticsMode } from '../../../../../common/types/trace_analytics';
import { coreRefs } from '../../../../framework/core_refs';
Expand Down Expand Up @@ -81,7 +76,7 @@
spanId: string;
isFlyoutVisible: boolean;
closeFlyout: () => void;
addSpanFilter: (field: string, value: any) => void;

Check warning on line 79 in public/components/trace_analytics/components/traces/span_detail_flyout.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
mode: TraceAnalyticsMode;
dataSourceMDSId: string;
serviceName?: string;
Expand All @@ -91,11 +86,11 @@
setCurrentSpan?: React.Dispatch<React.SetStateAction<string>>;
}) {
const { mode } = props;
const [span, setSpan] = useState<any>({});

Check warning on line 89 in public/components/trace_analytics/components/traces/span_detail_flyout.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

useEffect(() => {
handleSpansFlyoutRequest(props.http, props.spanId, setSpan, mode, props.dataSourceMDSId);
}, [props.spanId]);

Check warning on line 93 in public/components/trace_analytics/components/traces/span_detail_flyout.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has missing dependencies: 'mode', 'props.dataSourceMDSId', and 'props.http'. Either include them or remove the dependency array

const getListItem = (
fieldKey: string | undefined,
Expand Down Expand Up @@ -307,15 +302,14 @@
const redirectToExplorer = () => {
const spanId = getSpanValue(span, mode, 'SPAN_ID');
const spanField = getSpanFieldKey(mode, 'SPAN_ID');
coreRefs?.application!.navigateToApp(observabilityLogsID, {
path: `#/explorer`,
state: {
DEFAULT_DATA_SOURCE_NAME,
DEFAULT_DATA_SOURCE_TYPE,
queryToRun: `source = ss4o_logs-* | where ${spanField}='${spanId}'`,
startTimeRange: props.startTime,
endTimeRange: props.endTime,
},
coreRefs?.application!.navigateToApp('data-explorer', {
path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:${
props.startTime
},to:${props.endTime}))&_q=(filters:!(),query:(dataset:(dataSource:(id:'${
props.dataSourceMDSId ?? ''
}',title:'',type:DATA_SOURCE),id:'${
props.dataSourceMDSId
}::ss4o_logs-*',timeFieldName:'%40timestamp',title:'ss4o_logs-*',type:INDEXES),language:PPL,query:'source%20%3D%20ss4o_logs-*%20%7C%20where%20${spanField}%20%3D%20!'${spanId}!''))`,
});
};

Expand Down
Loading