diff --git a/public/app/features/explore/TraceView/TraceView.tsx b/public/app/features/explore/TraceView/TraceView.tsx index b6610e26f12..f44534301dd 100644 --- a/public/app/features/explore/TraceView/TraceView.tsx +++ b/public/app/features/explore/TraceView/TraceView.tsx @@ -64,10 +64,20 @@ type Props = { datasource: DataSourceApi | undefined; topOfViewRef?: RefObject; createSpanLink?: SpanLinkFunc; + focusedSpanId?: string; + createFocusSpanLink?: (traceId: string, spanId: string) => LinkModel; }; export function TraceView(props: Props) { - const { traceProp, datasource, topOfViewRef, exploreId, createSpanLink: createSpanLinkFromProps } = props; + const { + traceProp, + datasource, + topOfViewRef, + exploreId, + createSpanLink: createSpanLinkFromProps, + focusedSpanId: focusedSpanIdFromProps, + createFocusSpanLink: createFocusSpanLinkFromProps, + } = props; const { detailStates, @@ -101,13 +111,16 @@ export function TraceView(props: Props) { */ const [spanNameColumnWidth, setSpanNameColumnWidth] = useState(0.4); - const [focusedSpanId, createFocusSpanLink] = useFocusSpanLink({ + const [focusedSpanIdExplore, createFocusSpanLinkExplore] = useFocusSpanLink({ refId: props.dataFrames[0]?.refId, exploreId: props.exploreId!, datasource, splitOpenFn: props.splitOpenFn!, }); + const focusedSpanId = focusedSpanIdFromProps ?? focusedSpanIdExplore; + const createFocusSpanLink = createFocusSpanLinkFromProps ?? createFocusSpanLinkExplore; + const traceTimeline: TTraceTimeline = useMemo( () => ({ childrenHiddenIDs, diff --git a/public/app/plugins/panel/traces/TracesPanel.tsx b/public/app/plugins/panel/traces/TracesPanel.tsx index 62a02cce75d..f33e04f64eb 100644 --- a/public/app/plugins/panel/traces/TracesPanel.tsx +++ b/public/app/plugins/panel/traces/TracesPanel.tsx @@ -2,7 +2,7 @@ import { css } from '@emotion/css'; import React, { useMemo, createRef } from 'react'; import { useAsync } from 'react-use'; -import { PanelProps } from '@grafana/data'; +import { Field, LinkModel, PanelProps } from '@grafana/data'; import { getDataSourceSrv } from '@grafana/runtime'; import { TraceView } from 'app/features/explore/TraceView/TraceView'; import { SpanLinkFunc } from 'app/features/explore/TraceView/components'; @@ -17,6 +17,8 @@ const styles = { export interface TracesPanelOptions { createSpanLink?: SpanLinkFunc; + focusedSpanId?: string; + createFocusSpanLink?: (traceId: string, spanId: string) => LinkModel; } export const TracesPanel = ({ data, options }: PanelProps) => { @@ -44,6 +46,8 @@ export const TracesPanel = ({ data, options }: PanelProps) = datasource={dataSource.value} topOfViewRef={topOfViewRef} createSpanLink={options.createSpanLink} + focusedSpanId={options.focusedSpanId} + createFocusSpanLink={options.createFocusSpanLink} /> );