mirror of
https://github.com/grafana/grafana.git
synced 2025-01-16 11:42:35 -06:00
TraceViewer: Fix trace to logs icon to show in right pane (#31414)
This commit is contained in:
parent
ba6f30da9c
commit
2c62425be7
@ -288,14 +288,18 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
renderTraceViewPanel() {
|
renderTraceViewPanel() {
|
||||||
const { queryResponse, splitOpen } = this.props;
|
const { queryResponse, splitOpen, exploreId } = this.props;
|
||||||
const dataFrames = queryResponse.series.filter((series) => series.meta?.preferredVisualisationType === 'trace');
|
const dataFrames = queryResponse.series.filter((series) => series.meta?.preferredVisualisationType === 'trace');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// We expect only one trace at the moment to be in the dataframe
|
// We expect only one trace at the moment to be in the dataframe
|
||||||
// If there is no data (like 404) we show a separate error so no need to show anything here
|
// If there is no data (like 404) we show a separate error so no need to show anything here
|
||||||
dataFrames[0] && (
|
dataFrames[0] && (
|
||||||
<TraceView trace={dataFrames[0].fields[0].values.get(0) as TraceViewData | undefined} splitOpenFn={splitOpen} />
|
<TraceView
|
||||||
|
exploreId={exploreId}
|
||||||
|
trace={dataFrames[0].fields[0].values.get(0) as TraceViewData | undefined}
|
||||||
|
splitOpenFn={splitOpen}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,14 @@ import { TraceView } from './TraceView';
|
|||||||
import { TracePageHeader, TraceTimelineViewer } from '@jaegertracing/jaeger-ui-components';
|
import { TracePageHeader, TraceTimelineViewer } from '@jaegertracing/jaeger-ui-components';
|
||||||
import { TraceSpanData, TraceData } from '@grafana/data';
|
import { TraceSpanData, TraceData } from '@grafana/data';
|
||||||
import { setDataSourceSrv } from '@grafana/runtime';
|
import { setDataSourceSrv } from '@grafana/runtime';
|
||||||
|
import { ExploreId } from 'app/types';
|
||||||
|
|
||||||
jest.mock('react-redux', () => ({
|
jest.mock('react-redux', () => ({
|
||||||
useSelector: jest.fn(() => undefined),
|
useSelector: jest.fn(() => undefined),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function renderTraceView() {
|
function renderTraceView() {
|
||||||
const wrapper = shallow(<TraceView trace={response} splitOpenFn={() => {}} />);
|
const wrapper = shallow(<TraceView exploreId={ExploreId.left} trace={response} splitOpenFn={() => {}} />);
|
||||||
return {
|
return {
|
||||||
timeline: wrapper.find(TraceTimelineViewer),
|
timeline: wrapper.find(TraceTimelineViewer),
|
||||||
header: wrapper.find(TracePageHeader),
|
header: wrapper.find(TracePageHeader),
|
||||||
@ -37,7 +38,7 @@ describe('TraceView', () => {
|
|||||||
it('does not render anything on missing trace', () => {
|
it('does not render anything on missing trace', () => {
|
||||||
// Simulating Explore's access to empty response data
|
// Simulating Explore's access to empty response data
|
||||||
const trace = [][0];
|
const trace = [][0];
|
||||||
const { container } = render(<TraceView trace={trace} splitOpenFn={() => {}} />);
|
const { container } = render(<TraceView exploreId={ExploreId.left} trace={trace} splitOpenFn={() => {}} />);
|
||||||
expect(container.hasChildNodes()).toBeFalsy();
|
expect(container.hasChildNodes()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20,13 +20,14 @@ import { TraceViewData, Trace, TraceSpan, TraceKeyValuePair, TraceLink } from '@
|
|||||||
import { createSpanLinkFactory } from './createSpanLink';
|
import { createSpanLinkFactory } from './createSpanLink';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { StoreState } from 'app/types';
|
import { StoreState } from 'app/types';
|
||||||
import { SplitOpen } from 'app/types/explore';
|
import { ExploreId, SplitOpen } from 'app/types/explore';
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
import { TraceToLogsData } from 'app/core/components/TraceToLogsSettings';
|
import { TraceToLogsData } from 'app/core/components/TraceToLogsSettings';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
trace?: TraceViewData;
|
trace?: TraceViewData;
|
||||||
splitOpenFn: SplitOpen;
|
splitOpenFn: SplitOpen;
|
||||||
|
exploreId: ExploreId;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TraceView(props: Props) {
|
export function TraceView(props: Props) {
|
||||||
@ -59,7 +60,7 @@ export function TraceView(props: Props) {
|
|||||||
|
|
||||||
const traceProp = useMemo(() => transformTraceData(props.trace), [props.trace]);
|
const traceProp = useMemo(() => transformTraceData(props.trace), [props.trace]);
|
||||||
const { search, setSearch, spanFindMatches } = useSearch(traceProp?.spans);
|
const { search, setSearch, spanFindMatches } = useSearch(traceProp?.spans);
|
||||||
const dataSourceName = useSelector((state: StoreState) => state.explore.left.datasourceInstance?.name);
|
const dataSourceName = useSelector((state: StoreState) => state.explore[props.exploreId]?.datasourceInstance?.name);
|
||||||
const traceToLogsOptions = (getDatasourceSrv().getInstanceSettings(dataSourceName)?.jsonData as TraceToLogsData)
|
const traceToLogsOptions = (getDatasourceSrv().getInstanceSettings(dataSourceName)?.jsonData as TraceToLogsData)
|
||||||
?.tracesToLogs;
|
?.tracesToLogs;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user