mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 01:41:24 -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() {
|
||||
const { queryResponse, splitOpen } = this.props;
|
||||
const { queryResponse, splitOpen, exploreId } = this.props;
|
||||
const dataFrames = queryResponse.series.filter((series) => series.meta?.preferredVisualisationType === 'trace');
|
||||
|
||||
return (
|
||||
// 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
|
||||
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 { TraceSpanData, TraceData } from '@grafana/data';
|
||||
import { setDataSourceSrv } from '@grafana/runtime';
|
||||
import { ExploreId } from 'app/types';
|
||||
|
||||
jest.mock('react-redux', () => ({
|
||||
useSelector: jest.fn(() => undefined),
|
||||
}));
|
||||
|
||||
function renderTraceView() {
|
||||
const wrapper = shallow(<TraceView trace={response} splitOpenFn={() => {}} />);
|
||||
const wrapper = shallow(<TraceView exploreId={ExploreId.left} trace={response} splitOpenFn={() => {}} />);
|
||||
return {
|
||||
timeline: wrapper.find(TraceTimelineViewer),
|
||||
header: wrapper.find(TracePageHeader),
|
||||
@ -37,7 +38,7 @@ describe('TraceView', () => {
|
||||
it('does not render anything on missing trace', () => {
|
||||
// Simulating Explore's access to empty response data
|
||||
const trace = [][0];
|
||||
const { container } = render(<TraceView trace={trace} splitOpenFn={() => {}} />);
|
||||
const { container } = render(<TraceView exploreId={ExploreId.left} trace={trace} splitOpenFn={() => {}} />);
|
||||
expect(container.hasChildNodes()).toBeFalsy();
|
||||
});
|
||||
|
||||
|
@ -20,13 +20,14 @@ import { TraceViewData, Trace, TraceSpan, TraceKeyValuePair, TraceLink } from '@
|
||||
import { createSpanLinkFactory } from './createSpanLink';
|
||||
import { useSelector } from 'react-redux';
|
||||
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 { TraceToLogsData } from 'app/core/components/TraceToLogsSettings';
|
||||
|
||||
type Props = {
|
||||
trace?: TraceViewData;
|
||||
splitOpenFn: SplitOpen;
|
||||
exploreId: ExploreId;
|
||||
};
|
||||
|
||||
export function TraceView(props: Props) {
|
||||
@ -59,7 +60,7 @@ export function TraceView(props: Props) {
|
||||
|
||||
const traceProp = useMemo(() => transformTraceData(props.trace), [props.trace]);
|
||||
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)
|
||||
?.tracesToLogs;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user